1

I am attempting to do some DML on a Custom Meta Data record, to allow users to have some "Defaults" when a managed package is installed, that we would also like them to be able to manipulate (and save via APEX).

However, I am receiving errors when I attempt to perform DML operations in Apex:

Default_Property_Mapping__mdt mapping = new Default_Property_Mapping__mdt();
mapping.Field_Name_c = 'test';
mapping.SFDC_Object_Name__c = 'Contact';
insert mapping;

The meta data type Visibility is set to Public and the Field Malleability is set to Subscriber Editable, however, I am thinking that the guide is ambiguous on this point that this does not make these "records" editable in APEX

2

Apex code can create, read, and update (but not delete) custom metadata records, as long as the metadata is subscriber-controlled and visible from within the code's namespace. DML operations aren’t allowed on custom metadata in the Partner or Enterprise APIs. With unpackaged metadata, both developer-controlled and subscriber-controlled access behave the same: like subscriber-controlled access.

Please refer for more details on custom meta-data

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.