Newer Version Available

This content describes an older version of this product. View Latest

Operations Class

Represents a class to execute metadata operations, such as retrieving or deploying custom metadata.

Namespace

Metadata

Usage

Use the Metadata.Operations class to execute metadata operations. For more information on use cases and restrictions of metadata operations in Apex, see Metadata.

Example: Retrieve Metadata

The following example retrieves the “MyTestCustomMDType” custom metadata record from the subscriber org, and inspects the custom fields.

Example: Deploy Metadata

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.

Operations Methods

The following are methods for Operations.

clone()

Makes a duplicate copy of the Metadata.Operations.

Signature

public Object clone()

Return Value

Type: Object

enqueueDeployment(container, callback)

Deploys custom metadata components asynchronously.

Signature

public static Id enqueueDeployment(Metadata.DeployContainer container, Metadata.DeployCallback callback)

Parameters

container
Type: Metadata.DeployContainer
Container that contains the set of metadata components to deploy.
callback
Type: Metadata.DeployCallback
A class that implements the Metadata.DeployCallback interface. Used by Salesforce to return information about the deployment results.

Return Value

Type: Id

ID of deployment request.

retrieve(type, fullNames)

Retrieves a list of custom metadata components.

Signature

public static List<Metadata.Metadata> retrieve(Metadata.MetadataType type, List<String> fullNames)

Parameters

type
Type: Metadata.MetadataType
The metadata component type.
fullNames
Type: List<String>
A list of component names to retrieve. For information on component name formats, see Metadata.fullName().

Return Value

Type: List<Metadata.Metadata>