The repo currently supports creating, updating & deploying CMDT records via backend automations (Apex and Flow) - this PR adds a new lightning web component custom-metadata-table that provides a way for users to create, update & deploy CMDT records through custom UIs (lwc, aura components and screen Flows).
Using custom-metadata-table component
The component can be used within screen Flows or within other lightning web/aura components. It requires 3 parameters:
records - an instance of List<SObject> in Apex, or a 'record collection' within Flow, containing the CMDT records to display within the table. All of the SObject records must be of the same SObject Type. You can create or query the list of CMDT records - see README for details on how to create CMDT records in Apex and All CMDT records must have both fields DeveloperName and MasterLabel populated in order to successfully deploy the new records.
fieldsToDisplay - a comma-separated list of field API names that should be shown in the table. When the paremeter enableEditing == true, all fields, except DeveloperName and lookup fields, will be editable within the table. This is done via the lightning-datatable's inline-editing functionality
enableEditing - Boolean value to control if CMDT records are displayed in read-only mode (enableEditing == false) or with inline-editing enabled (enableEditing == true)
Flow Example
These screenshots show an example of using the component within Flow. In this first image, Flow's Get Record feature is used to query CMDT records in the CMDT object CustomMetadataDeployTest__mdt - but everything is done dynamically, so you can use any custom metadata type (CMDT) object.
Once you've queried or created a record collection containing CMDT records, you can add a screen that uses the `Custom Metadata Table' component.
The End Result
Once the table is configured, it displays the CMDT records in a lighting-datatable component
When users edit 1 or more fields, the standard Save and Cancel buttons are automatically displayed on the lightning-datable component:
When a user clicks Cancel, any unsaved changes to the CMDT records are discarded, and all field values are reverted to their original value.
When a user clicks Save, a loading-spinner is displayed to prevent any additional changes while the CMDT records are deployed asynchronously to the current org. Once the deployment finishes (either by successfully deploying the CMDT records or by failing due to an error), then the component removes the loading-spinner-icon, and users can resume interacting with the component.
Possible Future Enhancements
This PR provides the core functionality for a CMDT-based datatable, but there are definitely some features currently missing - hopefully these features (and others) will be added in future releases
Picklist fields are not currently properly rendered as a picklist - this PR's code renders them as a text field, which works, but this needs to be addressed in a future
New button/action to create a new CMDT record from within the table
Column sorting functionality
Ability to navigate to a CMDT record's 'View' page (under Setup)
The repo currently supports creating, updating & deploying CMDT records via backend automations (Apex and Flow) - this PR adds a new lightning web component
custom-metadata-table
that provides a way for users to create, update & deploy CMDT records through custom UIs (lwc, aura components and screen Flows).Using
custom-metadata-table
componentThe component can be used within screen Flows or within other lightning web/aura components. It requires 3 parameters:
records
- an instance ofList<SObject>
in Apex, or a 'record collection' within Flow, containing the CMDT records to display within the table. All of theSObject
records must be of the sameSObject Type
. You can create or query the list of CMDT records - see README for details on how to create CMDT records in Apex and All CMDT records must have both fieldsDeveloperName
andMasterLabel
populated in order to successfully deploy the new records.fieldsToDisplay
- a comma-separated list of field API names that should be shown in the table. When the paremeterenableEditing == true
, all fields, exceptDeveloperName
and lookup fields, will be editable within the table. This is done via thelightning-datatable
's inline-editing functionalityenableEditing
- Boolean value to control if CMDT records are displayed in read-only mode (enableEditing == false
) or with inline-editing enabled (enableEditing == true
)Flow Example
These screenshots show an example of using the component within Flow. In this first image, Flow's
Get Record
feature is used to query CMDT records in the CMDT objectCustomMetadataDeployTest__mdt
- but everything is done dynamically, so you can use any custom metadata type (CMDT) object.Once you've queried or created a record collection containing CMDT records, you can add a screen that uses the `Custom Metadata Table' component.
The End Result
Once the table is configured, it displays the CMDT records in a
lighting-datatable
componentWhen users edit 1 or more fields, the standard
Save
andCancel
buttons are automatically displayed on thelightning-datable
component:Cancel
, any unsaved changes to the CMDT records are discarded, and all field values are reverted to their original value.Save
, a loading-spinner is displayed to prevent any additional changes while the CMDT records are deployed asynchronously to the current org. Once the deployment finishes (either by successfully deploying the CMDT records or by failing due to an error), then the component removes the loading-spinner-icon, and users can resume interacting with the component.Possible Future Enhancements
This PR provides the core functionality for a CMDT-based datatable, but there are definitely some features currently missing - hopefully these features (and others) will be added in future releases
New
button/action to create a new CMDT record from within the table