I want to update the DeveloperName field via Apex in a Custom MetadataType. I would like to replace "VALUE1" with "VALUE2". Instead, however, it just inserts another line. Is it possible to update DeveloperName via Apex at this time (since Delete is not supported as of yet)?

Metadata.CustomMetadata customMetadata =  new Metadata.CustomMetadata();
customMetadata.fullName = 'MySetting__mdt.VALUE2';
customMetadata.label = 'MyLabel';

Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();

Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, null);

enter image description here

1 Answer 1


This isn't possible. The Apex Metadata API essentially uses the file-based Metadata API under the covers, and it's not possible to use the file-based Metadata API to rename components.

  • Except, I've found you can certainly update other fields using Apex Metadata API. Just haven't figured out if there's a way to update the "DeveloperName" field. Use this: sfdcpanther.com/create-update-custom-metadata-using-apex and this: corevalue.net/deploying-custom-metadata-records-apex-code for reference. Oct 17, 2019 at 18:33
  • I guess it can't be changed. Unfortunately, "DeveloperName" was the field I was relying on to set Mule environments. Any hopes of writing post deployment scripts to set this field to the correct setting is now gone. I have to flip this to custom settings now and change it in 30 different places. Oct 18, 2019 at 15:29
  • 1
    In general, I really don't recommend using the DeveloperName field for anything but identifying the record. Oct 18, 2019 at 21:28
  • 1
    Basically, you can't update that field because, from the perspective of the Apex MD API (or the regular MD API, for that matter), developer name (together with namespace) is used to identify what record you're talking about. If you change the name, it has no way of knowing that you mean the original record. Oct 18, 2019 at 21:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .