I have a situation where I would like to deploy records of custom metadata types from one sandbox to another through Apex. The reason for using Apex is that there will be a lot of records under the same parent metadata record and I would like to pick them up dynamically and deploy them to another sandbox so the user doesn't have to click on each record through change sets. The records are not static between different clients(orgs) so I can't create a single script to always execute on each org. I have looked at the Metadata namespace, but found no information or examples on how to deploy from one sandbox to another. Did anyone ever try to do something similar or knows if it can be done?

  • 3rd party commercial dev/devops tools are very good at this.
    – identigral
    Commented Sep 15, 2023 at 17:12

1 Answer 1


You just need some kind of Metadata API Wrapper to deploy metadata between orgs, even Custom Metadata records. Alternatively, you could manually create a wrapper for use with the Metadata REST or SOAP API.

You must log in to answer this question.

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