0

I am trying to edit custom metadata record using lwc. But it is not allowing me to do that. It is showing in read-only format. Here what I have tried,

<lightning-card title="Card Title">
    <lightning-record-edit-form record-id="m050o000000000H" object-api-name="CustomMetadata__mdt">
        <lightning-messages>
        </lightning-messages>
        <lightning-input-field field-name="Label">
        </lightning-input-field>
        <lightning-input-field field-name="FirstName">
        </lightning-input-field>
        <lightning-input-field field-name="LastName">
        </lightning-input-field>
    </lightning-record-edit-form>

Here my requirement to edit the custom metadata record and save it to database. But it is not showing in edit format. Can you suggest any idea or approach to accomplish this one.

Thank you.

1
  • I think you need to use the metadata API to update it from the apex. Jan 29 at 12:06
2

Custom Metadata records are not data; they are metadata. As such, these are designed to be edited by Admins using the Setup UI and cannot be edited using conventional DML operations.

You can create your own Apex code that uses the Metadata API to support a custom LWC allowing specific changes to certain types of Custom Metadata. You should note, however, that this API is intended for setup purposes rather than frequent data editing, and that changes to custom metadata records have an impact on performance (since caching of the records is naturally disrupted).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.