I have a custom metadata type "Project Literals" which have records that contain custom field ids
example: Label: StatusFieldId Name: StatusFieldId Id Field: 00N8E000000XYuM
Using DML statements give me an error "Id Field is not writable"
Is there a way to update the value using apex? maybe by using Metadata API, but how?
From the Custom Metadata Types Implementation Guide (page 9, emphasis mine):
Access Custom Metadata Types and Records
Use SOQL to access your custom metadata types and to retrieve the API names of the records on those types. DML operations aren’t allowed on custom metadata in Apex, the Partner APIs, and Enterprise APIs.
To make DML-like operations, you might also be interested in the apex/visualforce Custom Metadata Loader by Salesforce. It's open source on GitHub and has to make use of the Metadata API behind the scenes.
Related question: https://salesforce.stackexchange.com/questions/110482/can-we-update-records-of-custom-metadata-type-in-visualforce-page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With