-
Notifications
You must be signed in to change notification settings - Fork 93
soqlDatatable: Configurable Flow and LWC actions
Note: There is additional config needed for this feature. Please see the configuration steps.
Each soqlDatatable
can be have one defined Action Configuration (Datatable_Config__mdt
) to define both Table level (supporting multi / single select) and Row Level actions. This can be the same Datatable_Config__mdt
as used in the Lookup Configuration section.
Because of a limitation with cmdt, the Type__c
on the parent Datatable_Config__mdt
must be text of Actions
. For combined configs, use Actions; Lookups
.
Both LWCs (inside a dialog) and Screen Flows can be launched from either action type. The configuration is easier to explain in picture format:
The button is configured to the SOQL_Datatable_Flow_Action_Update_Contacts_with_New_Account
Screen Flow.
Note: Due to how data is constructed in
soqlDatatable
, you cannot use theSelectedRows
directly in aUpdate Records
. Always assign values you specifically want to update to a new Record Variable that is not an output ofsoqlDatatable
, which in this example isContactShell
/ContactToUpdate
.
This button configured to open the checkOpportunitiesExample
LWC.
Notice the public attributes, these are always supplied by soqlDatatable
when invoking an LWC.
<template>
<c-message-service boundary={uniqueBoundary}></c-message-service>
<template if:true={queryString}>
<c-soql-datatable query-string={queryString}></c-soql-datatable>
</template>
<template if:false={queryString}>
<div class="slds-align_absolute-center">
No Contacts Selected. Please choose contacts to view opportunities for.
</div>
</template>
</template>
...
@api uniqueBoundary;
@api selectedRows;
@api sourceRecordId;
queryString;
// private
_isRendered;
_messageService;
_accountIdSet = new Set();
connectedCallback() {
if (this.selectedRows && this.selectedRows.length) {
this.selectedRows.forEach(row => {
this._accountIdSet.add(`'${row.AccountId}'`);
});
}
if (this._accountIdSet.size > 0) {
let accountIds = Array.from(this._accountIdSet.keys());
this.queryString = convertToSingleLineString`
SELECT Account.Name, Name, Amount, CloseDate, StageName
FROM Opportunity
WHERE AccountId IN (${accountIds.join(',')})
ORDER BY Account.Name ASC
`;
}
}
...
The button is configured to the SOQL_Datatable_Flow_Row_Action_Remove_Contact_Phone
Screen Flow.
Note: Due to how data is constructed in
soqlDatatable
, you cannot use theFirstSelectedRecord
directly in anUpdate Records
. Always assign values you specifically want to update to a new Record Variable that is not an output ofsoqlDatatable
, which in this example isContactToUpdate
.