Accessing CDT Field Properties

Certified Lead Developer

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

Parents
  • I'm not aware of any functionality that will let you do this within Appian.

    Can you elaborate a bit on your use case? Maybe there's a different way to fulfill your requirement.
  • 0
    Certified Lead Developer
    in reply to Colton Beck

    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. */
      }
    )

  • With respect to maintenance, I agree with Harrison that you should try to homogenize your field lengths as much as possible to reduce the number of exceptions to handle. We generally use 255 characters for normal text fields and 4000 characters for paragraph fields, but your requirements will dictate what's best for you. If you have strict rules around specific limits for each field, you'll likely need to build that into your LOE unless it's possible to push back on the business to standardize these across the board.

    Unfortunately, I don't have an answer to your second questions. I'm not able to find any shared components that provide this functionality either.
  • 0
    Certified Lead Developer
    in reply to Colton Beck
    Yes, I agree and we have standardized the starting length of fields; over a long enough timeframe however these tend to evolve independently. I appreciate your input.
Reply Children
No Data