pacx column create - neronotte/Greg.Xrm.Command GitHub Wiki

(DEPRECATED. Use specialized column add <type> commands instead) Creates a new column on a given Dataverse table

Aliases

pacx create column

Usage

This section is a work in progress

This command allows you to create a new column on a given Dataverse table. You can specify various attributes of the column, such as its name, type, format, and other properties, and the command will automatically infer the remaining ones basing on the conventions described in the table below. The following sections describe how to generate each specific type of column.

Text (String) column

It's the type of column created by default if you simply type

pacx column create -t tableName -n columnName

The system will automatically generate a column of type text with the following features:

  • Display Name: columnName
  • Schema Name: publisherprefix_columnName (all lowercase without special chars or spaces)
  • Type: String
  • Format: Text
  • Max Length: 100
  • Required: None
  • Audit Enabled: true

You can manually set all other arguments in the following way:

# Specify a different format (supported values are: Email, Text, TextArea, Url, TickerSymbol, Phone, Json, RichText)
pacx column create -t tableName -n columnName --stringFormat Email

# Specify a different max length (default is 100)
pacx column create -t tableName -n columnName --len 200

# Create a required field (supported values are: None, ApplicationRequired, Recommended)
pacx column create -t tableName -n columnName -r ApplicationRequired

# Disable auditing for this column
pacx column create -t tableName -n columnName --audit false

# Create a column with a description
pacx column create -t tableName -n columnName -d "This is a description of the column"

# Create a column of type TextArea or RichText, required
pacx column create -t tableName -n columnName --stringFormat TextArea --len 2000 -r ApplicationRequired 
pacx column create -t tableName -n columnName --stringFormat RichText --len 2000 -r ApplicationRequired 

# Create a column of type Json
pacx column create -t tableName -n columnName --stringFormat Json --len 4000

If you want to create an autonumber field, you can use the --autoNumber option. The format must be specified in the form of a string, using the same syntax as the one used in the maker portal. For example, you can use {SEQNUM(5)} to create a 5-digit autonumber field.

# Example value: XX-00001
pacx column create -t tableName -n columnName --autonumber "XX-{SEQNUM(5)}"

# Example value: 123456-#-R3V
pacx column create -t tableName -n columnName --autonumber "{SEQNUM:6}-#-{RANDSTRING:3}"

# Example value: CAS-002000-S1P0H0-20170913091544
pacx column create -t tableName -n columnName --autonumber "CAS-{SEQNUM:6}-{RANDSTRING:6}-{DATETIMEUTC:yyyyMMddhhmmss}"

# Example value: CAS-002000-201709-Z8M2Z6-110901
pacx column create -t tableName -n columnName --autonumber "CAS-{SEQNUM:6}-{DATETIMEUTC:yyyyMM}-{RANDSTRING:6}-{DATETIMEUTC:hhmmss}"

Multiline String (Memo) column

It's a different type of String column, that by default accepts more than one line of text

pacx column create --type Memo -t tableName -n columnName

The system will automatically generate a column of type Memo with the following features:

  • Display Name: columnName
  • Schema Name: publisherprefix_columnName (all lowercase without special chars or spaces)
  • Type: Memo
  • Format: Text
  • Max Length: 2000
  • Required: None
  • Audit Enabled: true

You can manually set all other arguments in the following way:

# Specify a different format (Email, Json, RichText, Text, TextArea)
pacx column create --type Memo -t tableName -n columnName --memoFormat RichText

# Specify a different max length (default is 2000)
pacx column create --type Memo -t tableName -n columnName --len 200

# Create a required field (supported values are: None, ApplicationRequired, Recommended)
pacx column create --type Memo -t tableName -n columnName -r ApplicationRequired

True/False (Boolean) column

# Creates a simple true/false column
pacx column create --type Boolean -t tableName -n columnName

# Change the labels for True and False values
pacx column create --type Boolean -t tableName -n columnName --trueLabel Yes --falseLabel No

Whole Number (Integer) column

# Creates a simple integer column
pacx column create --type Integer -t tableName -n columnName

# Set minimum and maximum values
pacx column create --type Integer -t tableName -n columnName --min 0 --max 100

# Specify integer format (None, Duration, TimeZone, Language, Locale)
pacx column create --type Integer -t tableName -n columnName --intFormat Duration

Currency (Money) column

# Creates a simple money column with precision 2
pacx column create --type Money -t tableName -n columnName

# Set precision and precision source
pacx column create --type Money -t tableName -n columnName --precision 4 --precisionSource 0

# Set minimum and maximum values
pacx column create --type Money -t tableName -n columnName --min 0 --max 1000000

Decimal/Double Number column

This type of column is used for storing decimal numbers with a specified precision and range. If you specify "Decimal" as the type, the system will automatically generate a column that in the maker UI is shown as DataType=Decimal. If you specify "Double" as the type, the system will automatically generate a column that in the maker UI is shown as DataType=Float.

# Creates a simple decimal column with precision 2
pacx column create --type Decimal -t tableName -n columnName
pacx column create --type Double -t tableName -n columnName

# Set precision and min/max values
pacx column create --type Decimal -t tableName -n columnName --precision 4 --min 0 --max 999.99
pacx column create --type Double -t tableName -n columnName --precision 4 --min 0 --max 999.99

Choice (Picklist) column

This type of column is used for storing a single choice from a predefined list of options. You can create a simple picklist with options, or use an existing global option set. If you want to create a local option set column you can:

  • Specify only the options labels, separated by commas, semicolons or pipes (|). The system will automatically generate the values for you.
  • Specify the options as "label1:value1,label2:value2" to create a picklist with custom values.

As of now, you cannot specify a color for the picklist options.

Please note that if you specify the values, values must be specified for all options, and they must be unique. If you don't specify the values, the system will generate them automatically starting from the Publisher OptionSetPrefix + 0000.

If you want to create a multi-select picklist, you can use the --multiselect option. If you want to use an existing global option set, you can use the --globalOptionSetName option.

# Creates a simple picklist with options
pacx column create --type Picklist -t tableName -n columnName --options "Option 1,Option 2,Option 3"

# Create picklist with custom values
pacx column create --type Picklist -t tableName -n columnName --options "Red:100000000,Green:100000001,Blue:100000002"

# Create multi-select picklist
pacx column create --type Picklist -t tableName -n columnName --options "Tag1,Tag2,Tag3" --multiselect

# Use existing global option set
pacx column create --type Picklist -t tableName -n columnName --globalOptionSetName existing_global_optionset

You can also specify a default value for the picklist using the --defaultValue option. You can provide either the label or the value of the option (labels are matched first).

# Create picklist with default value by label
pacx column create --type Picklist -t tableName -n columnName --options "Red:100000000,Green:100000001,Blue:100000002" --defaultValue Green
# Create picklist with default value by value
pacx column create --type Picklist -t tableName -n columnName --options "Red,Green,Blue" --defaultValue 100000001 # Green
pacx column create --type Picklist -t tableName -n columnName --options "Red:100000000,Green:100000001,Blue:100000002" --defaultValue 100000001

DateTime column

# Creates a simple date and time column
pacx column create --type DateTime -t tableName -n columnName

# Create date-only column
pacx column create --type DateTime -t tableName -n columnName --dateTimeBehavior DateOnly --dateTimeFormat DateOnly
pacx column create --type DateTime -t tableName -n columnName -dtb DateOnly -dtf DateOnly

# Create time-zone independent datetime
pacx column create --type DateTime -t tableName -n columnName --dateTimeBehavior TimeZoneIndependent

# Create user local datetime with date and time format
pacx column create --type DateTime -t tableName -n columnName --dateTimeBehavior UserLocal --dateTimeFormat DateAndTime

File column

# Creates a simple file column
pacx column create --type File -t tableName -n columnName

# specifies the max allowed size in KB (10 MB)
pacx column create --type File -t tableName -n columnName --maxSizeInKB 10240
pacx column create --type File -t tableName -n columnName -maxKb 10240

Image column

# Creates a simple file column
pacx column create --type File -t tableName -n columnName

# specifies the max allowed size in KB (10 MB)
pacx column create --type File -t tableName -n columnName --maxSizeInKB 10240
pacx column create --type File -t tableName -n columnName -maxKb 10240

You can also specify if the image column should store only thumbnail-sized images using the --canStoreOnlyThumbnailImage option.

# Create image column that stores only thumbnail-sized images
pacx column create --type Image -t tableName -n columnName --storeOnlyThumbnailImage
pacx column create --type Image -t tableName -n columnName -thumb

To generate a thumbnail-sized image, Dataverse will crop and resize the image to a square shape according to the following rules:

  • Images with at least one side larger than 144 pixels are cropped on center to 144x144.
  • Images with both sides smaller than 144 are cropped square to their smallest side.

See this article to get more info.

Lookup column

Lookup column creation is not supported. You should use pacx rel create n1 command to generate a relationship, and the lookup column will be created automatically.

Arguments

Long Name Short Name Required? Description Default value Valid values
name n Y The display name of the attribute. - String
table t Y The name of the entity for which you want to create an attribute - String
audit a N Indicates whether the attribute is enabled for auditing (default: true). - true, false
autoNumber an N In case of autonumber field, the autonumber format to apply. - String
dateTimeBehavior dtb N For DateTime type columns indicates the DateTimeBehavior of the column. UserLocal UserLocal, TimeZoneIndependent, DateOnly
dateTimeFormat dtf N For DateTime type columns indicates the DateTimeFormat of the column. DateAndTime DateOnly, DateAndTime
defaultValue dv N For Picklist type columns indicates the default value for the column. You can provide the name or the value. If not provided, is automatically evaluated by the system. - String
description d N The description of the attribute. - String
falseLabel fl N For Boolean type columns that represents the Label to be associated to the "False" value. False String
globalOptionSetName gon N For Picklist type columns that must be tied to a global option set, provides the name of the global option set. - String
imeMode ime N For number type columns indicates the input method editor (IME) mode for the column. Disabled Auto, Inactive, Active, Disabled
intFormat if N For whole number type columns indicates the integer format for the column.(default: None) - None, Duration, TimeZone, Language, Locale
len l N The maximum length for string attribute. - Int32
max max N For number type columns indicates the maximum value for the column. - Double
maxSizeInKB maxKb N For File or Image type columns indicates the maximum size in KB for the column. Do not provide a value if you want to stay with the default (32Mb for file columns, 10Mb for image columns). The value must be lower than 10485760 (1Gb) for file columns, and lower than 30720 (30Mb) for image columns . - Int32
memoFormat mf N The format of the memo attribute (default: Text). Text Email, Json, RichText, Text, TextArea
min min N For number type columns indicates the minimum value for the column. - Double
multiselect m N Indicates whether the attribute is a multi-select picklist (default: false). False true, false
options o N The list of options for the attribute, as a single string separated by comma (,) or semicolon (;) or pipe. You can pass also values separating using syntax "label1:value1,label2:value2" If not provided, values will be automatically generated - String
precision p N For money or decimal type columns indicates the precision for the column. 2 Int32
precisionSource ps N For money type columns indicates if precision should be taken from: (0) the precision property, (1) the Organization.PricingDecimalPrecision attribute or (2) the TransactionCurrency.CurrencyPrecision property of the transaction currency that is associated the current record. 2 Int32
requiredLevel r N The required level of the attribute. - None, SystemRequired, ApplicationRequired, Recommended
schemaName sn N The schema name of the attribute. If not specified, is deducted from the display name - String
solution s N The name of the unmanaged solution to which you want to add this attribute. - String
storeOnlyThumbnailImage thumb N For Image type columns indicates if the column stores only thumbnail-sized images. False Boolean
stringFormat sf N The format of the string attribute (default: Text). - Email, Text, TextArea, Url, TickerSymbol, PhoneticGuide, VersionNumber, Phone, Json, RichText
trueLabel tl N For Boolean type columns that represents the Label to be associated to the "True" value. True String
type at N The type of the attribute. String String, Memo, Boolean, Integer, Money, Decimal, Double, Picklist, DateTime, Lookup, File, Image
⚠️ **GitHub.com Fallback** ⚠️