---
schema_version: "1"
id: 87ed31cf040c53f505ae1e81fa45921c51a8ce99d63c5b6af08f3dd23f9236c9
title: CustomMetadata Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Metadata_CustomMetadata.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 950eba3a5ffca10d7a93c64b05cf1bdcbe9bda7a558115855f13ced0608de24d
description: Represents records of custom metadata types.The description of the custom metadata.The label of the custom metadata record.Property that describes whether the custom metadata record is a protected component.A list of custom metadata values, such as custom fields, for the custom metadata record.Makes a duplicate copy of the Metadata.CustomMetadata.
---
# CustomMetadata Class

Represents records of custom metadata types.

## Namespace

![Warning](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_warning.png)

#### 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](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.CustomMetadata to represent records of custom metadata types in Apex. For more information, see [Custom Metadata Types](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_custommetadatatypes.htm) 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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)

#### 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', where _Namespace_ is a placeholder value.

- **[CustomMetadata Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_properties)**
- **[CustomMetadata Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_methods)**

## CustomMetadata Properties

The following are properties for CustomMetadata.

- **[description](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_description)**  
    The description of the custom metadata.
- **[label](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_label)**  
    The label of the custom metadata record.
- **[protected\_x](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_protected_x)**  
    Property that describes whether the custom metadata record is a protected component.
- **[values](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_CustomMetadata_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](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.")

### label

The label of the custom metadata record.

#### Signature

public String label {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.")

### 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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### 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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm#apex_methods_system_list "Contains methods for the List collection type.")<[Metadata.CustomMetadataValue](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadataValue.htm#apex_class_Metadata_CustomMetadataValue "Represents custom metadata values for a custom metadata component.")\>

## CustomMetadata Methods

The following are methods for CustomMetadata.

- **[clone()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_CustomMetadata.htm#apex_Metadata_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