PACX is a powerful tool for managing Dataverse environments. It allows you to automate tasks, including creating tables, columns, and relations. In this blog post, we’ll focus on creating columns of type Choice (Picklist) using PACX.
Choice column types
Dataverse provides 2 types of Choice column types: normal and multiselect.
Both can be bounded to a Local Option Set or to a Global Option Set.
PACX command allows to create all those combinations:
# create a normal picklist, with a local option set
pacx column create --type Picklist --table my_table --name Semaphore --options "Green,Yellow,Red"
pacx column create -at Picklist -t my_table -n Semaphore -o "Green,Yellow,Red"
# create a normal picklist, bound to a global option set
pacx column create --type Picklist --table my_table --name Semaphore --globalOptionSetName my_globaloptionset
pacx column create -at Picklist -t my_table -n Semaphore -gon my_globaloptionset
# create a multiselect picklist, with a local option set
pacx column create --type Picklist --table my_table --name Semaphore --options "Green,Yellow,Red" --multiselect
pacx column create -at Picklist -t my_table -n Semaphore -o "Green,Yellow,Red" -m
# create a multiselect picklist, bound to a global option set
pacx column create --type Picklist --table my_table --name Semaphore --globalOptionSetName my_globaloptionset --multiselect
pacx column create -at Picklist -t my_table -n Semaphore -gon my_globaloptionset -m
As usual, PACX will apply the following conventions:
-
SchemaName and LogicalName are built by
- taking the publisher prefix of the current default solution (
{prefix}
) - taking only letters, numbers or underscores from the specified
--name
({name}
)
- taking the publisher prefix of the current default solution (
-
RequiredLevel is set to
None
- Description is left empty
-
IsAuditEnabled field is set to
true
That can be overridden as described in the previous posts of this series.
PLEASE NOTE: At the moment of writing, for picklists bounded to Global Option Sets, the Option Set must have been previously created elsewhere for the command to complete successfully.
If you specify both
--globalOptionsetName
and--options
arguments, options is ignored.
The --options
argument accepts the list of picklist options (labels) as a single string separated by comma (,), semicolon (;) or pipe (|). Spaces around values are trimmed out and empty values are ignored. The numerical sequence of values paired with the provided labels is automatically generated starting from the optionSetPrefix
of the publisher currently selected.
This means that something like this:
# create a normal picklist, with a local option set
pacx column create ... --options "Green ,, Yellow|Red"
In the context of a solution whose publisher has optionSetPrefix
set to 10000, generates the following options:
- 100000000: <Green>
- 100000001: <Yellow>
- 100000002: <Red>
Remember to refer to the official PACX documentation for detailed information and additional options.
Happy coding! 🚀