CustomMetadata Class

Represents records of custom metadata types.

Namespace

Metadata

Usage

Use Metadata.CustomMetadata to represent records of custom metadata types in Apex. For more information, see Custom Metadata Types in the Metadata API Developer Guide.

Example

// Set up custom metadata to be created in the subscriber org.
    Metadata.CustomMetadata customMetadata =  new Metadata.CustomMetadata();
    customMetadata.fullName = 'ISVNamespace__MetadataTypeName.MetadataRecordName';

    Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
    customField.field = 'customField__c';
    customField.value = 'New value';

    customMetadata.values.add(customField);
Note

Note

When you assign namespaces to records, provide full, qualified record names to the app. If both the type and the record are in Namespace, use something like: customMetadata.fullName = 'Namespace__MetadataTypeName.Namespace__MetadataRecordName'

CustomMetadata Properties

The following are properties for CustomMetadata.

  • description
    The description of the custom metadata.
  • label
    The label of the custom metadata record.
  • protected_x
    Property that describes whether the custom metadata record is a protected component.
  • values
    A list of custom metadata values, such as custom fields, for the custom metadata record.

description

The description of the custom metadata.

Signature

public String description {get; set;}

Property Value

Type: String

label

The label of the custom metadata record.

Signature

public String label {get; set;}

Property Value

Type: String

protected_x

Property that describes whether the custom metadata record is a protected component.

Signature

public Boolean protected_x {get; set;}

Property Value

Type: Boolean

values

A list of custom metadata values, such as custom fields, for the custom metadata record.

Signature

public List<Metadata.CustomMetadataValue> values {get; set;}

Property Value

Type: List<Metadata.CustomMetadataValue>

CustomMetadata Methods

The following are methods for CustomMetadata.

  • clone()
    Makes a duplicate copy of the Metadata.CustomMetadata.

clone()

Makes a duplicate copy of the Metadata.CustomMetadata.

Signature

public Object clone()

Return Value

Type: Object