DEV Community

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

Posted on

PACX ⁓ Create columns: Numeric

Welcome to the 2nd article of the series where we show how to leverage PACX commands to create Dataverse columns.


Numeric columns

Dataverse supports 4 numeric column types:

  • Integer
  • BigInt
  • Decimal
  • Float (Double)

The first one does not accepts decimal values at all. The second can accept decimal values, with a predetermined precision (up to 10 decimal points). The third can accept decimal numbers with up to 5 points of precision.

Decimal numbers are stored in the database exactly as specified. Floating point numbers store an extremely close approximation of the value. Why choose extremely close approximation when you can have the exact value? The answer is that you get different system performance.

From Using the right type of number

There is also another numeric column type (Money), but we'll discuss about it in a dedicated post.

At the moment of writing, only Integer and Decimal columns types are supported by PACX (PACX is an open source community tool, feel free to drop a pull request to add the missing column types if you like!).

Integer columns

To create an Integer column you can type:

pacx column create --type Integer --table my_table --name "People Count"
pacx column create -at Integer -t my_table -n "People Count"
Enter fullscreen mode Exit fullscreen mode

Those are the only 3 arguments required to create an **Integer **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})
  • RequiredLevel is set to None
  • Description is left empty
  • IsAuditEnabled field is set to true
  • MinValue is set to .NET Int32.MinValue
  • MaxValue is set to .NET Int32.MaxValue

For integer columns, you can also specify one of the following formats, that drive the way the field is shown in Model Driven Apps:

  • None (default): A basic integer field.
  • Duration: Specifies to display the integer as a drop down list of durations.
  • TimeZone: Specifies to display the integer as a drop down list of time zones.
  • Language: Specifies the display the integer as a drop down list of installed languages.
  • Locale: Specifies a locale.

You can specify the format to apply using:

pacx column create --type Integer --table my_table --name Duration --intFormat Duration
pacx column create -at Integer -t my_table -n Duration -if Duration
Enter fullscreen mode Exit fullscreen mode

You can also override default min and max values using:

pacx column create --type Integer --table my_table --name Percent --min 0 --max 100
pacx column create -at Integer -t my_table -n Percent -min 0 -max 100
Enter fullscreen mode Exit fullscreen mode

Double columns

To create a Double column you can type:

pacx column create --type Double --table my_table --name Ratio
pacx column create -at Double -t my_table -n Ratio
Enter fullscreen mode Exit fullscreen mode

The same conventions specified for Integer fields apply, with a few minor differences:

  • 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})
  • RequiredLevel is set to None
  • Description is left empty
  • IsAuditEnabled field is set to true
  • MinValue is set to .NET Int64.MinValue (converted to .NET Decimal)
  • MaxValue is set to .NET Int64.MaxValue (converted to .NET Decimal)
  • Precision is set to 2

To specify a different precision you can type:

pacx column create --type Integer --table my_table --name Ratio --precision 5 
pacx column create -at Integer -t my_table -n Ratio -p 5
Enter fullscreen mode Exit fullscreen mode

To override min and max value, you can use:

pacx column create --type Integer --table my_table --name Ratio --min 10.35 --max 20.99
pacx column create -at Integer -t my_table -n Ratio -min 10.35 -max 100.99
Enter fullscreen mode Exit fullscreen mode

As usual, all those arguments can be 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)