cmdt generate field

Generate a field for a custom metadata type based on the provided field type.

Similar to a custom object, a custom metadata type has a list of custom fields that represent aspects of the metadata.

This command creates a metadata file that describes the new custom metadata type field. By default, the file is created in a “fields” directory in the current directory. Use the –output-directory to generate the file in the directory that contains the custom metadata type metdata files, such as “force-app/main/default/objects/MyCmdt__mdt” for the custom metadata type called MyCmdt.

force:cmdt:field:create

cmdt:field:create

Flag Name (Long)Flag Name (Short)Description
‑‑decimal‑places‑sType: Value

Number of decimal places to use for number or percent fields.

The value must be greater than or equal to zero. Default value is 0.
‑‑flags‑dirN/AType: Value

Import flag values from a directory.
‑‑jsonN/AType: Boolean

Format output as json.
‑‑label‑lType: Value

Label for the field.
‑‑name‑nType: Value
Required

Unique name for the field.
‑‑output‑directory‑dType: Value

Directory to store newly-created field definition files.

New files are automatically created in the “fields” directory. The location can be an absolute path or relative to the current working directory. The default is the current directory.
‑‑picklist‑values‑pType: Value

Picklist values; required for picklist fields.
‑‑type‑fType: Value
Required
Valid Values: Checkbox, Date, DateTime, Email, Number, Percent, Phone, Picklist, Text, TextArea, LongTextArea, Url

Type of the field.

You can’t use this command to create a custom metadata type field of type “Metadata Relationship”. Use the Salesforce Setup UI instead.

Generate a metadata file for a custom checkbox field and add the file to the MyCmdt__mdt/fields directory:

Generate a metadata file for a custom picklist field and add a few values:

Generate a metadata file for a custom number field and specify 2 decimal places: