Related list inline editing Salesforce
Ngày đăng:
15/01/2022
Trả lời:
0
Lượt xem:
26
Note: 1. Enter API Name of the child object in Object Name 2. Parent Field API Name should be the lookup or master-detail field API Name. 3. Filed Name is the API Name of the Field to filter. relatedList.html: object-api-name={objectName} layout-type="Compact" mode="view" columns="2"> relatedList.js: import { LightningElement, api, wire } from 'lwc'; import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; export default class RelatedList extends LightningElement { @api objectName; @api fieldName; @api fieldValue; @api parentFieldAPIName; @api recordId; @api strTitle; @api filterType; @api operator; get vals() { return this.recordId + ',' + this.objectName + ',' + this.parentFieldAPIName + ',' + this.fieldName + ',' + this.fieldValue + ',' + this.filterType + ',' + this.operator; } @wire(fetchRecords, { listValues: '$vals' }) records; } Apex Class: public class RelatedListController { @AuraEnabled( cacheable=true ) public static List < sObject > fetchRecords( String listValues ) { system.debug( 'values are ' + listValues ); List < String > strList = listValues.split( ',' ); system.debug( 'values are ' + strList ); if ( strList.size() == 7 ) { String recordId = strList.get( 0 ); String objectName = strList.get( 1 ); String parentFieldAPIName = strList.get( 2 ); String fieldName = strList.get( 3 ); String fieldValue = strList.get( 4 ); String filterType = strList.get( 5 ); String operator = strList.get( 6 ); String strSOQL = 'SELECT Id FROM ' + objectName + ' WHERE ' + parentFieldAPIName + ' = \'' + recordId + '\' AND '; if ( filterType == 'String' ) strSOQL += fieldName + ' = \'' + fieldValue + '\''; else if ( filterType == 'Boolean' ) strSOQL += fieldName + ' = ' + fieldValue; else strSOQL += fieldName + ' ' + operator + ' ' + fieldValue; strSOQL += ' LIMIT 10'; return Database.query( strSOQL ); } else return null; } } Configuring Attributes in Lightning App Builder: I have done the below configuration on the AccountLightningRecord Page.
Output: |