---
schema_version: "1"
id: a920254b32a6186ecdad3215c33a8f31cdbf9f2c3bd35f7830d8bfb9bdb5ccb8
title: CustomMetadataValue Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Metadata_CustomMetadataValue.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c3edd69cdc20a9cdd5cce139132c138b718de2124c4016c0b50e6f9d3a975a0b
description: Represents custom metadata values for a custom metadata component.The field name for the custom metadata value.The field value for the custom metadata value.Makes a duplicate copy of the Metadata.CustomMetadataValue.
---
# CustomMetadataValue Class

Represents custom metadata values for a custom metadata component.

## Namespace

[Metadata](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Metadata.htm "The Metadata namespace provides classes and methods for working with custom metadata in Salesforce")

## 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

// Set a custom field value for a custom metadata record
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
customField.field = 'CustomField1\_\_c';
customField.value = 'New Value';
customMetadata.values.add(customField);

- **[CustomMetadataValue Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_Metadata_CustomMetadataValue_properties)**
- **[CustomMetadataValue Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_Metadata_CustomMetadataValue_methods)**

## CustomMetadataValue Properties

The following are properties for CustomMetadataValue.

- **[field](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_Metadata_CustomMetadataValue_field)**  
    The field name for the custom metadata value.
- **[value](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_Metadata_CustomMetadataValue_value)**  
    The field value for the custom metadata value.

### field

The field name for the custom metadata value.

#### Signature

public String field {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### 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](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/langCon_apex_primitives.htm).

## CustomMetadataValue Methods

The following are methods for CustomMetadataValue.

- **[clone()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_Metadata_CustomMetadataValue_clone)**  
    Makes a duplicate copy of the Metadata.CustomMetadataValue.

### clone()

Makes a duplicate copy of the Metadata.CustomMetadataValue.

#### Signature

public Object clone()

#### Return Value

Type: Object