Newer Version Available
Security Considerations
Generally, Apex classes installed in the subscriber org can access any public, supported metadata type or component in the subscriber org. Protected metadata, such as a custom metadata type that’s been marked protected, can only be accessed by Apex classes in the same namespace as the protected metadata.
Additionally, for managed packages, if the managed package isn’t approved by Salesforce via security review, Apex classes in the package can’t access metadata (public or protected) unless the Deploy Metadata from Non-Certified Package Versions via Apex org preference is enabled. This preference, located under , must be enabled if admins or developers are installing managed packages that haven’t passed security review for app testing or pilot purposes.
For deployments, because Metadata.Operations.enqueueDeployment() uses asynchronous Apex, queued deployment jobs and deployment callbacks are counted as asynchronous jobs in the current org. Queued deployment jobs and callbacks are subject to governor limits. See Lightning Platform Apex Limits.
Apps that access metadata via Apex must notify users that the app can retrieve or deploy metadata in the subscriber org. For installs that access metadata, notify users in the description of your package. You can write your own notice, or use this sample:
This package can access and change metadata outside its namespace in the Salesforce org where it’s installed.
Salesforce verifies the notice during the security review. For more information, see the ISVforce Guide.