3

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?

3

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

Specifically:

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 here

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.