9 votes
Accepted

How to delete Custom MetaData Records Via Apex?

Yes, It is possible to delete metadata records using MetadataService.deleteMetadata method. Here is a sample method call that should work: List<String> recordsToDelete = new List<String>();...
Ashish Narkhede's user avatar
8 votes
Accepted

Impossible to test Metadata.Operations.enqueueDeployment method

You might use Test.isRunningTest(). It is considered to be a bad practice to use it but for covering this case this is the only option for now. Hopefully in the future Salesforce will add some Deploy ...
Patlatus's user avatar
  • 16.1k
6 votes

How to delete Custom MetaData Records Via Apex?

Right now, I don't think it is possible to delete metadata records via Apex - only create/update From the Trailhead Docs Although there’s a lot you can do with Apex Metadata API, there are some > ...
BritishBoyinDC's user avatar
4 votes
Accepted

How to Make Metadata.Operation deploy work?

Looks like we can't have DeployCallback defined in Anonymous Execution Window code. If we define DeployCallback as separate class or an inner class of some class saved in the organization (not ...
Patlatus's user avatar
  • 16.1k
3 votes
Accepted

Packaged CMDT record fails to update even for Sysadmin

Heaven (or Google) finally send me this article about Apex Metadata Deployments which states that: When you develop a managed package, only certified packages are allowed to use this feature of ...
Robert Sösemann's user avatar
2 votes

Error updating metadata via Apex

This is a known issue with 6 reports, currently tagged as Solution in Progress
Darren Henry's user avatar
2 votes

Error updating metadata via Apex

I am running into a nearly identical issue in my org that started just days ago. cropredy posted a link to A Possible Clue After looking at this post and the comments, there was some additional ...
SalesforceMike's user avatar
2 votes

Error updating metadata via Apex

From the Metadata API doc Users must have the Customize Application permission to create, update, and delete metadata records. Thereafter, users with the Modify Metadata Through Metadata API ...
cropredy's user avatar
  • 70k
1 vote

Packaged CMDT record fails to update even for Sysadmin

The official docs that describe why you need the setting is shared here From the docs Be aware of security considerations when accessing metadata using Apex. Generally, Apex classes installed in the ...
Mohith Shrivastava's user avatar
1 vote

Update Custom Metadata Type Record

We have installer code that does this sort of thing. The only difference I can see between what we do and what you have is that in order to update a custom metadata record we first retrieve it using (...
Phil W's user avatar
  • 34.3k

Only top scored, non community-wiki answers of a minimum length are eligible