cmdt Commands

Create and update custom metadata types and their records.

force:cmdt:create

Creates a new custom metadata type in the current project.

Command Syntax

sfdx force:cmdt:create
[--json]
[--loglevel LOGLEVEL]
-n TYPENAME
[-l LABEL]
[-p PLURALLABEL]
[-v VISIBILITY]
[-d OUTPUTDIR]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-n | --typename TYPENAME
Required

The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.

Type: string
-l | --label LABEL
Optional

A label for the custom metadata type.

Type: string
-p | --plurallabel PLURALLABEL
Optional

The plural version of the label value. If this flag is missing or blank, the singular label is used as the plural label.

Type: string
-v | --visibility VISIBILITY
Optional

The visibility of the custom metadata type.

Type: enum
Permissible values are: PackageProtected, Protected, Public
Default value: Public
-d | --outputdir OUTPUTDIR
Optional

The directory to store the newly-created custom metadata type files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: directory

force:cmdt:field:create

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

Command Syntax

sfdx force:cmdt:field:create
[--json]
[--loglevel LOGLEVEL]
-n FIELDNAME
-f FIELDTYPE
[-p PICKLISTVALUES]
[-s DECIMALPLACES]
[-l LABEL]
[-d OUTPUTDIR]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-n | --fieldname FIELDNAME
Required

The unique name for the field.

Type: string
-f | --fieldtype FIELDTYPE
Required

The unique name for the field.

Type: enum
Permissible values are: Checkbox, Date, DateTime, Email, Number, Percent, Phone, Picklist, Text, TextArea, LongTextArea, Url
-p | --picklistvalues PICKLISTVALUES
Optional

A comma-separated list of picklist values. These values are required when creating a Picklist field.

Type: array
-s | --decimalplaces DECIMALPLACES
Optional

The number of decimal places to use for Number or Percent fields. The value must be greater than or equal to zero.

Type: number
-l | --label LABEL
Optional

The label for the field.

Type: string
-d | --outputdir OUTPUTDIR
Optional

The directory to store the newly-created field definition files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: directory

force:cmdt:generate

Generates a custom metadata type and all its records for the provided sObject.

Command Syntax

sfdx force:cmdt:generate
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-n DEVNAME
[-l LABEL]
[-p PLURALLABEL]
[-v VISIBILITY]
-s SOBJECTNAME
[-i]
[-d TYPEOUTPUTDIR]
[-r RECORDSOUTPUTDIR]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-n | --devname DEVNAME
Required

The name of the custom metadata type.

Type: string
-l | --label LABEL
Optional

The label for the custom metadata type.

Type: string
-p | --plurallabel PLURALLABEL
Optional

The plural version of the label value. If this flag is missing or blank, the singular label is used as the plural label.

Type: string
-v | --visibility VISIBILITY
Optional

The visibility of the custom metadata type.

Type: enum
Permissible values are: PackageProtected, Protected, Public
Default value: Public
-s | --sobjectname SOBJECTNAME
Required

The API name of the sObject source for custom metadata generation.

Type: string
-i | --ignoreunsupported
Optional

Ignore unsupported field types (these fields will not be created). The default is to create Text fields and convert the source value to text.

Type: boolean
-d | --typeoutputdir TYPEOUTPUTDIR
Optional

The directory to store newly-created custom metadata type files.

Type: directory
Default value: force-app/main/default/objects/
-r | --recordsoutputdir RECORDSOUTPUTDIR
Optional

The directory to store newly-created custom metadata record files.

Type: directory
Default value: force-app/main/default/customMetadata/

force:cmdt:record:create

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

Command Syntax

sfdx force:cmdt:record:create
[--json]
[--loglevel LOGLEVEL]
-t TYPENAME
-n RECORDNAME
[-l LABEL]
[-p PROTECTED]
[-i INPUTDIR]
[-d OUTPUTDIR]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-t | --typename TYPENAME
Required

The API name of the custom metadata type to create a record for.

Type: string
-n | --recordname RECORDNAME
Required

The name for the new record.

Type: string
-l | --label LABEL
Optional

The label for the new record.

Type: string
-p | --protected PROTECTED
Optional

Protect the record when it is in a managed package. Protected records can only be accessed by code in the same managed package namespace.

Type: string
Permissible values are: true, false
Default value: false
-i | --inputdir INPUTDIR
Optional

The directory to pull the custom metadata type definition from.

Type: directory
Default value: force-app/main/default/objects
-d | --outputdir OUTPUTDIR
Optional

The directory to store newly-created custom metadata record files.

Type: directory
Default value: force-app/main/default/customMetadata

force:cmdt:record:insert

Create new custom metadata type records from a CSV file.

Command Syntax

sfdx force:cmdt:record:insert
[--json]
[--loglevel LOGLEVEL]
-f FILEPATH
-t TYPENAME
[-i INPUTDIR]
[-d OUTPUTDIR]
[-n NAMECOLUMN]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-f | --filepath FILEPATH
Required

The path to the CSV file.

Type: string
-t | --typename TYPENAME
Required

The API Name of the custom metadata type. The '__mdt' suffix will be appended to the end of the name if it is omitted.

Type: string
-i | --inputdir INPUTDIR
Optional

The directory to pull the custom metadata type definition from.

Type: directory
Default value: force-app/main/default/objects
-d | --outputdir OUTPUTDIR
Optional

The directory to store newly-created custom metadata record files.

Type: directory
Default value: force-app/main/default/customMetadata
-n | --namecolumn NAMECOLUMN
Optional

The column that is used to determine the name of the record.

Type: string
Default value: Name