I have a beta-managed-package the when deployed has a Apex Metadata API call out that allows users to modify some Custom Metadata that is shipped via the the code. It also allows them to create new Custom Metadata Entries.

This works fine in scratch orgs, and our packaging org, however, we discovered when we installed the beta-package in another developer or scratch org that the Metadata was not deploying after we called:

Metadata.Operations.enqueueDeployment(container, callback);

I captured the exception in a custom field and it says:

Not allowed to install metadata via apex.

I am only installing for Admins, whom have Modify all data permissions, and all the fields on the Custom Metadata type are subscriber editable?

Any ideas?

1 Answer 1


Never mind, I found it: https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/packaging_metadata_in_apex.htm,


Managed packages not approved by Salesforce can’t access metadata in the subscriber org, unless the subscriber org enables the Allow metadata deploy by Apex from non-certified Apex package version org preference. Use this org preference when doing test or beta releases of your managed packages.

And in Deploy Metadata from Non-Certified Package Versions via Apex - what does it mean, which outlines where to find the applicable org preference.

You must log in to answer this question.

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