Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

CustomMetadataValue Class

Represents custom metadata values for a custom metadata component.

Namespace

Metadata

Usage

Use Metadata.CustomMetadataValue to access values for custom fields of custom metadata records.

Supported Apex primitive types are:
  • Boolean
  • Date
  • DateTime
  • Decimal
  • Double
  • Integer
  • Long
  • String

Example

1// Set a custom field value for a custom metadata record
2Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
3customField.field = 'CustomField1__c';
4customField.value = 'New Value';
5customMetadata.values.add(customField);

CustomMetadataValue Properties

The following are properties for CustomMetadataValue.

field

The field name for the custom metadata value.

Signature

public String field {get; set;}

Property Value

Type: String

value

The field value for the custom metadata value.

Signature

public Object value {get; set;}

Property Value

Type: Object

Supported Apex primitive types are:
  • Boolean
  • Date
  • DateTime
  • Decimal
  • Double
  • Integer
  • Long
  • String

When setting the value for relationship fields, use the qualified API name of the related metadata, not the ID.

For more information, see Primitive Data Types.

CustomMetadataValue Methods

The following are methods for CustomMetadataValue.

clone()

Makes a duplicate copy of the Metadata.CustomMetadataValue.

Signature

public Object clone()

Return Value

Type: Object