CustomMetadata Class

Represents records of custom metadata types.

Namespace

Warning

Warning

Protected custom metadata types behave like public custom metadata types when they are outside of a managed package. Public custom metadata types are readable for all profiles, including the guest user. Do not store secrets, personally identifying information, or any private data in these records. Use protected custom metadata types only in managed packages. Outside of a managed package, use named credentials or encrypted custom fields to store secrets like OAuth tokens, passwords, and other confidential material.

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.

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.

Signature

public Object clone()

Return Value

Type: Object