jongpie / CustomMetadataSaver

Allows saving changes to custom metadata records via Apex and Flow
MIT License
39 stars 5 forks source link

New 'custom metadata table' lightning web component #10

Closed jongpie closed 3 years ago

jongpie commented 3 years ago

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:

  1. 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.
  2. 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
  3. 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.

image

Once you've queried or created a record collection containing CMDT records, you can add a screen that uses the `Custom Metadata Table' component.

image

The End Result

Once the table is configured, it displays the CMDT records in a lighting-datatable component

image

When users edit 1 or more fields, the standard Save and Cancel buttons are automatically displayed on the lightning-datable 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

jamessimone commented 3 years ago

🎉!