Is there a function available that would allow me to access a CDT's field properties, i.e. the Length of a Text field on a CDT?
Discussion posts and replies are publicly visible
I have a reusable interface expression rule that receives an input named entity of type AnyType ( see code snippet below ). I expect the entity to have a specific attribute which in this case is name, i.e. ri!entity.name. We pass in different types of CDT's to the interface expression and all these CDT's must have name as an attribute. The length constraint of the name attribute may however differ from one CDT to another. So, the first problem I am trying to solve is to avoid having to create a constant representing the length constrain of a particular CDT field as this creates clutter and may lead to maintenance issues. The second problem I am trying to solve is to enable a level of dynamic validation based on the CDT type and attribute constraints; for example, something like this would be useful > type!MyCDT.name.length or fn!metadata(entity,"name").length.
a!textField( label: "Name", labelPosition: if( ri!disabled, "ADJACENT", "ABOVE" ), disabled: ri!disabled, value: ri!entity.name, saveInto: ri!entity.name, validations: { /* Validate the field length, etc. */ } )