# cmdt generate record

Generate a new record for a given custom metadata type in the current project.

## Description for cmdt generate record

The custom metadata type must already exist in your project. You must specify a name for the new record. Use name=value pairs to specify the values for the fields, such as MyTextField="some text here" or MyNumberField=32.

## Aliases for cmdt generate record

`force:cmdt:record:create`

`cmdt:record:create`

## Flags

| Flag Name (Long)     | Flag Name (Short) | Description                                                                                                                                                                                                                               |
| -------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--flags-dir`        | N/A               | **Type:** Value<br><br>Import flag values from a directory.                                                                                                                                                                               |
| `--input-directory`  | `-i`              | **Type:** Value<br>**Default value:** `force-app/main/default/objects`<br><br>Directory from which to get the custom metadata type definition from.                                                                                       |
| `--json`             | N/A               | **Type:** Boolean<br><br>Format output as json.                                                                                                                                                                                           |
| `--label`            | `-l`              | **Type:** Value<br><br>Label for the new record.                                                                                                                                                                                          |
| `--output-directory` | `-d`              | **Type:** Value<br>**Default value:** `force-app/main/default/customMetadata`<br><br>Directory to store newly-created custom metadata record files.                                                                                       |
| `--protected`        | `-p`              | **Type:** Value<br>**Valid Values:** `true`, `false`<br>**Default value:** `false`<br><br>Protect the record when it's in a managed package.<br><br>Protected records can only be accessed by code in the same managed package namespace. |
| `--record-name`      | `-n`              | **Type:** Value<br>**Required**<br><br>Name of the new record.                                                                                                                                                                            |
| `--type-name`        | `-t`              | **Type:** Value<br>**Required**<br><br>API name of the custom metadata type to create a record for; must end in "__mdt".                                                                                                                  |

## Examples for cmdt generate record

Create a record metadata file for custom metadata type 'MyCMT' with specified values for two custom fields:

```shell
sf cmdt generate record --type-name MyCMT__mdt --record-name MyRecord My_Custom_Field_1=Foo My_Custom_Field_2=Bar
```

Create a protected record metadata file for custom metadata type 'MyCMT' with a specific label and values specified for two custom fields:

```shell
sf cmdt generate record --type-name MyCMT__mdt --record-name MyRecord --label "My Record" --protected true My_Custom_Field_1=Foo My_Custom_Field_2=Bar
```
