Operations Class
Represents a class to execute metadata operations, such as retrieving or deploying custom metadata.
Use the Metadata.Operations class to execute metadata operations. For more information on use cases and restrictions of metadata operations in Apex, see Metadata.
The following example retrieves the “MyTestCustomMDType” custom metadata record from the subscriber org, and inspects the custom fields.
The following example uses the Metadata API in Apex to update the customField custom field value of the MetadataRecordName custom metadata record and deploy this change into the subscriber org. Because the deployment is asynchronous, you must provide a callback class that implements the Metadata.DeployCallback interface, which is then used when the queued deployment completes.
Create a metadata record along with another one that references it in the same transaction. If the parent record was installed with a namespace, prefix the developer name with recordNs__.
No custom metadata relationship can relate records of the same type to each other.
The following are methods for Operations.
-
Makes a duplicate copy of the
Metadata.Operations. -
enqueueDeployment(container, callback)
Deploys custom metadata components asynchronously.
-
Retrieves a list of custom metadata components.
Makes a duplicate copy of the Metadata.Operations.
public Object clone()
Type: Object
Deploys custom metadata components asynchronously.
To preserve service function, we limit the number of Metadata API deployments originating from Apex that can be enqueued at a time. See Limit on Enqueued Deployments from Apex
public static Id enqueueDeployment(Metadata.DeployContainer container, Metadata.DeployCallback callback)
-
container:
Type: Metadata.DeployContainer
Container that contains the set of metadata components to deploy.
-
callback:
Type: Metadata.DeployCallback
A class that implements the
Metadata.DeployCallbackinterface. Used by Salesforce to return information about the deployment results.
Type: Id
ID of deployment request.
Retrieves a list of custom metadata components.
public static List<Metadata.Metadata> retrieve(Metadata.MetadataType type, List<String> fullNames)
-
type:
Type: Metadata.MetadataType
The metadata component type.
-
fullNames:
A list of component names to retrieve. For information on component name formats, see Metadata.fullName().
Type: List<Metadata.Metadata>