Skip to content

soqlDatatable: Configurable Flow and LWC actions

James Hou edited this page Jan 31, 2021 · 3 revisions

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:

soql-datatable-config-mdt

Assign New Account - Flow Table Action

The button is configured to the SOQL_Datatable_Flow_Action_Update_Contacts_with_New_Account Screen Flow.

soql-datatable-new-account-flow

Note: Due to how data is constructed in soqlDatatable, you cannot use the SelectedRows directly in a Update Records. Always assign values you specifically want to update to a new Record Variable that is not an output of soqlDatatable, which in this example is ContactShell/ContactToUpdate.

Check Opportunities - LWC Table Action

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
        `;
    }
}

...

Remove Phone - Flow Row Action

The button is configured to the SOQL_Datatable_Flow_Row_Action_Remove_Contact_Phone Screen Flow.

soql-datatable-remove-contact-phone-flow

Note: Due to how data is constructed in soqlDatatable, you cannot use the FirstSelectedRecord directly in an Update Records. Always assign values you specifically want to update to a new Record Variable that is not an output of soqlDatatable, which in this example is ContactToUpdate.

Clone this wiki locally