We’re developing a workflow in which the user will use a Workshop application to enter some data to populate the properties of an object in the ontology.
Two of the properties of the object type are width and depth. At the moment, we’re prompting the user to ensure these dimensions are in centimetres, but it would be better if we could specifically define the properties to use centimetres.
I’m wondering if anyone has had a similar use case, and could share some advice? We’ve thought about using value types, but uncertain if this is the best way to go!
You can do this using Value formatting, where you can specify the unit. This will show a value of 8 as 8cm in workshop or other ontology-aware applications. On some units it will also allow you to choose different formats of the same unit, so 8 hours versus 8h.
We are dealing with a lot of units in our company. Usually, we keep two columns for this purpose, since it is the easiest we to have value-unit pair available in calculations. This is usually the case when data comes from a source system.
If you would like the user to enter the dimension only in cm, you can configure the basetype in the display section of the property in the ontology manager.
If you would like to enforce that the user writes “1cm” or “1 cm” instead of “1”. You could make the action function based, take the string as an input parameter and do a regex evaluation before storing it as a number in your DoubleType column, and throw a “UserFacingError” if validation fails.
Similar to @Flackermann 's process, once struct properties are GA, another alternative is to create a struct property type with 2 fields- one for the value and the other to represent the units.
While using a structured field is certainly feasible, I would recommend following @Flackermann’s suggestion—have two columns per dimension (measurement as Double, unit type as String).
This will make things easier for pipelines/workshop aggregations/etc.