# cmdt generate records

Generate new custom metadata type records from a CSV file.

## Description for cmdt generate records

The custom metadata type must already exist in your project. By default, the Name column is used to determine the record name; use the --name-column flag to specify a different column.

## Aliases for cmdt generate records

`force:cmdt:record:insert`

`cmdt:record:insert`

## Flags

| Flag Name (Long)     | Flag Name (Short) | Description                                                                                                                                                                       |
| -------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--csv`              | `-f`              | **Type:** Value<br>**Required**<br><br>Pathname of the CSV file.                                                                                                                  |
| `--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.                                                                                                                                   |
| `--name-column`      | `-n`              | **Type:** Value<br>**Default value:** `Name`<br><br>Column used to determine the name of the 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.                               |
| `--type-name`        | `-t`              | **Type:** Value<br>**Required**<br><br>API name of the custom metadata type to create a record for.<br><br>The '__mdt' suffix is appended to the end of the name if it's omitted. |

## Examples for cmdt generate records

Generate record metadata files from values in a CSV file for the custom metadata type MyCmdt. Use 'Name' as the column that specifies the record name:

```shell
sf cmdt generate records --csv path/to/my.csv --type-name MyCmdt
```

Generate record metadata files from a CSV file in the directory different from the default, and use 'PrimaryKey' as the column that specifies the record name:

```shell
sf cmdt generate records --csv path/to/my.csv --type-name MyCmdt --input-directory path/to/my/cmdt/directory --name-column "PrimaryKey"
```
