LWC Dynamic Custom Metadata Mass Data Editor

Process of inserting or updating deleting or reading custom metadata records. This LWC will allow users to insert, update, delete, or read custom metadata using a CSV file upload. This component is particularly useful for Salesforce administrators and developers who need to manage large sets of custom metadata records efficiently.

Features

  1. Insert, Update, Delete, or Read Custom Metadata: The component provides options to perform CRUD (Create, Read, Update, Delete) operations on custom metadata records.
  2. Dynamic Custom Metadata Selection: Based on the selected operation, the component dynamically fetches and displays available custom metadata types in the org.
  3. CSV File Upload: Users can upload a CSV file for bulk insert update or delete operations.
  4. Download Metadata: Users can query and download custom metadata records in CSV format.

Detailed Explanation of Features

1. Insert, Update, Delete, or Read Custom Metadata

This LWC component allows users to select one of the four operations: Insert, Update, Delete, or Read. The component adapts depending on the selected operation to provide the necessary inputs and actions.

  • Insert: When inserting custom metadata, the component prompts the user to select the metadata type and upload a CSV file containing the records to be inserted.
  • Update: Similar to insert, but the CSV file should contain records with identifiers to be updated.
  • Delete: Users can upload a CSV file containing the identifiers of the records to be deleted.
  • Read: This operation allows users to query and download existing custom metadata records in CSV format.

2. Dynamic Custom Metadata Selection

The component dynamically fetches the available custom metadata types from the org. When the user selects an operation (except Read), the component displays a dropdown list of custom metadata types, allowing the user to choose the type they want to work with.

3. CSV File Upload

For Insert, Update, and Delete operations, the component provides an input field to upload a CSV file. The CSV file should contain the necessary data for the selected operation. The component reads the file content and processes it accordingly.

4. Download Metadata

For the Read operation, users can query custom metadata records and download them in CSV format. This feature is particularly useful for exporting metadata for backup or analysis purposes.

Demo: Managing Custom Metadata with LWC

Insert Custom Metadata

  1. Choose Type: Select “Insert” from the operation options.
  2. Select Metadata Type: Choose the appropriate custom metadata type (e.g., MetaData__mdt).
  3. Upload File: Select your CSV file from your local system.

4. Click Upload CSV File: Click the “Upload CSV File” button to start the upload process.

Note: Your CSV file must include columns for Label and DeveloperName.

Update Custom Metadata

  1. Choose Type: Select “Update” from the operation options.
  2. Select Metadata Type: Choose the appropriate custom metadata type (e.g., MetaData__mdt).
  3. Upload File: Select your CSV file from your local system.

4.Click Upload CSV File: Click the “Upload CSV File” button to start the update process.

Note: Your CSV file must include columns for Label and DeveloperName.

Delete Custom Metadata

  1. Choose Type: Select “Delete” from the operation options.
  2. Select Metadata Type: Choose the appropriate custom metadata type (e.g., MetaData__mdt).
  3. Upload File: Select your CSV file from your local system.

4. Click Upload CSV File: Click the “Upload CSV File” button to start the deletion process.

Note: Your CSV file must include a DeveloperName column.

Read Custom Metadata

  1. Choose Type: Select “Read” from the operation options.
  2. Enter Your Metadata Query: Input your SOQL query, for example, SELECT Id, Label, DeveloperName FROM MetaData__mdt LIMIT 10.
  1. Click Validate the Query: Click the “Validate Query” button to ensure your query is correct.
    • If you click Export: The results will be exported and available for download.
    • If you click Download: The results will be downloaded to your local system.

Implementation Steps

Step 1: Create the LWC Component

  1. HTML Template:
    • Create the HTML template for the LWC to include input fields and buttons for various operations.(code shared separate file)

        2.  JavaScript Controller:

  • Create the JavaScript controller to handle the logic for different operations and CSV file processing.(code shared separate file)

Step 2: Apex Controller

  • Create an Apex controller to handle fetching custom metadata types and performing CRUD operations based on the CSV file. (code shared separate file)

Conclusion

With this functionality, you can efficiently manage custom metadata records in your Salesforce org using a user-friendly interface. This tool simplifies the process of bulk inserting, updating, deleting, and querying custom metadata, making it a valuable addition to any Salesforce administrator or developer’s toolkit.

Additional Tips

  1. CSV Format: Document the required CSV format for each operation to avoid user confusion and errors during file uploads.

Leave A Comment

All fields marked with an asterisk (*) are required