diff --git a/README.md b/README.md index 048d1e4..24d6e0d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Custom Data types (the component extendedDatatable extends lightning:datatable) | Enter Related field API Name | :x: | String | Enter related field API name | Example AccountId for contact when component is on account layout. | | Formula Image Field API Names | :x: | String | Enter formula field API names **Note** : This is mandatory for formula fields displaying images | \["FormulaField__c"\] | | Hide/Unhide checkbox column | :x: | Boolean | true/false | Hide/Unhide Checkbox | -| Enter WHERE clause | :x: | String | provide aditional filters | Example `LastName like '%s' AND Account.Name like '%t'` | +| Enter WHERE clause | :x: | String | provide aditional filters | Example `LastName like '%s' AND Account.Name like '%t' AND AccountId = 'recordId' AND CreatedById = 'connectedUserId'`
**Note** : `'recordId' filter support detail page only` | | Group by | :x: | String | set the group by clause | Example `AccountId` | | Order by | :x: | String | set the order by clause | Example `LastName, Account.Name DESC` | | Enter limit | :x: | Integer | limit the displayed number of records for the list | an integer | diff --git a/force-app/main/default/lwc/lwcRelatedList/lwcRelatedList.js b/force-app/main/default/lwc/lwcRelatedList/lwcRelatedList.js index cf6733c..c861c85 100644 --- a/force-app/main/default/lwc/lwcRelatedList/lwcRelatedList.js +++ b/force-app/main/default/lwc/lwcRelatedList/lwcRelatedList.js @@ -20,6 +20,7 @@ import { } from './lwcRelatedListHelper'; import recordUpdatedSuccessMessage from '@salesforce/label/c.recordUpdatedSuccessMessage'; import recordDeletedSuccessMessage from '@salesforce/label/c.recordDeletedSuccessMessage'; +import Id from "@salesforce/user/Id"; const actions = [ { label: 'Show details', name: 'show_details' }, { label: 'Edit', name: 'edit' }, @@ -51,6 +52,7 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) { @api lookupFilterConfigJSON; // Private Property @api oldPredefinedCol = ''; + connectedUserId = Id @track data; @track soql; @track offSet = 0; @@ -460,7 +462,15 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) { let where = []; if (this.relatedFieldAPI) where.push(`${this.relatedFieldAPI} = '${this.recordId}'`); - if (this.whereClause) where.push(this.whereClause); + if (this.whereClause) { + where.push(this.whereClause); + if(this.whereClause.includes('recordId')){ + this.whereClause.replace('recordId', this.recordId) + } + if(this.whereClause.includes('connectedUserId')){ + this.whereClause.replace('connectedUserId', this.connectedUserId) + } + } if (this.lookupFilterCondition) where.push(this.lookupFilterCondition); return where.length > 0 ? ` WHERE ${where.join(' AND ')} ` : ''; }