DEV Community

Cover image for PACX ⁓ Create columns: Text
Riccardo Gregori
Riccardo Gregori

Posted on

PACX ⁓ Create columns: Text

We have previously described how to create tables easily with PACX.

Now we'll deep dive on how to fill the table we've created with columns.

I think pacx column create (or its alias pacx create column) is the most complex command we've created so far, basically due to the high number column types available in the Dataverse, and the high number of parameters available for each column type.

We started building it incrementally, one column type at time, starting from the simplest one: text columns


You can create a basic text column via

pacx column create --table my_table --name "Full Name"
pacx column create -t my_table -n "Full Name"
Enter fullscreen mode Exit fullscreen mode

Those are the only 2 arguments required to create a text column. PACX assumes 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})
    • contatenating {prefix}_{name}
  • MaxLength is set to 100
  • StringFormat is set to Text
  • RequiredLevel is set to None
  • Description is left empty
  • IsAuditEnabled field is set to true

Of course you can override all those defaults using all the other optional arguments provided by the command.

You can provide your own custom schema name, if the default generated by PACX doesn't matches your naming rules. You can do it leveraging the schemaName argument:

pacx column create --table my_table --name "Full Name" --schemaName my_table_full_name
pacx column create -t my_table -n "Full Name" -sn my_table_full_name
Enter fullscreen mode Exit fullscreen mode

PACX checks if the schema name you provided matches the publisher prefix of the solution in which the field will be created. If they don't match, the command returns an error.

If you want to create the command in the context of a solution that is not the one set as default for your environment, or you don't have a default solution set for your environment, you can specify the solution via solution argument:

pacx column create --table my_table --name Code --solution my_solution_unique_name
pacx column create -t my_table -n Code -s my_solution_unique_name
Enter fullscreen mode Exit fullscreen mode

The command allows you to do a lot more: if you want, for instance, to create an AutoNumber text field, you can simply type:

pacx column create --table my_table --name Code --autoNumber "C-{SEQNUM:8}"
pacx column create -t my_table -n Code -an "C-{SEQNUM:8}"
Enter fullscreen mode Exit fullscreen mode

If you want to override the default max length:

pacx column create --table my_table --name Code --len 20
pacx column create -t my_table -n Code -l 20
Enter fullscreen mode Exit fullscreen mode

If you want to create the field with audit disabled:

pacx column create --table my_table --name "Full Name" --audit false
pacx column create -t my_table -n "Full Name" -a false
Enter fullscreen mode Exit fullscreen mode

If you want to provide a description for the field:

pacx column create --table my_table --name "Full Name" --description "The full name of the client"
pacx column create -t my_table -n "Full Name" -d "The full name of the client"
Enter fullscreen mode Exit fullscreen mode

If you want to create different a different type of text field (e.g. Email, TextArea, Url, Json, ...), you can leverage the stringFormat argument:

pacx column create --table my_table --name "Full Name" --stringFormat Email
pacx column create -t my_table -n "Full Name" -sf Email
Enter fullscreen mode Exit fullscreen mode

All those arguments can be of course mixed in a single command execution to build the field as you need. Just type

pacx column create --help
Enter fullscreen mode Exit fullscreen mode

To get the list, and a quick help, on all available arguments.

Top comments (0)