Preferred way to create a Constant based on a Record Type

Hi Guys, what is the prefered way to create and use constants in an appian application.

I have created the following record types "Order", "Order Lines", "Order Type" and "Order Status".

The "Order" Record Type has an orderTypeId (Number - integer) and orderStatusId (Number - integer) fields and relationships added to these tables. 

I have now created two constants called "CONS_ORDER_TYPE" and "CONS_ORDER_STATUS" which binds directly to the above mentioned Record Types.

How would you use these two constants in eg. a dropdown list? 

I mean, if you create a constant of type array and add text values {"Created","On Hold", "Fulfilled"} what is the purpose to create the "Record Type" entities for the constants (Order Type and Order Status) since you can just use the data type "text" for the orderStatusId and orderTypeId fields on the "Order" record type.

  Discussion posts and replies are publicly visible

  • You put that constant containing a string array in the choiceLabels of the dropdown, and then what would you put in the choiceValues? You would need another array with the respective identifiers and then save those relationship, no? Isn't easier managing all that with a record type? And yes, you could declare orderStatusId and orderTypeId as text and write down the strings directly there, but when you have a few milion rows and you try to execute any massive database operation you'll regret, even if the columns are indexed depending on some cases.

  • Using "Record Types" for things like Order Status or Order Type is generally the better approach, especially as the application grows.

    If you only use a constant with a text array such as {"Created","On Hold","Fulfilled"}, it may work for small cases, but it becomes harder to manage when you need to add new statuses, change labels, support translations, or maintain relationships in the database.

    With "Record Types", you keep a proper reference table where each status or type has an **ID and a label**. The dropdown can then use the record data source, for example using the status name as `choiceLabels` and the status ID as `choiceValues`. This keeps the database normalized and allows you to safely store only the IDs in the Order record.

    Another advantage is maintainability. If a new status is added later, you just insert a new record instead of updating constants or redeploying rules.

    So in practice, the constants that reference the **Order Type** and **Order Status** record types are useful as centralized references, and the dropdown can simply query those record types to populate the options dynamically.

  • 0
    Certified Lead Developer

    Use Record Types with integer FK as the preferred approach, since it enables proper relationships, filtering, and reporting.
    Your orderStatusId stores the integer Id, and the dropdown fetches labels from the Order Status record type via a!queryRecordType().
    Drop the text array constants - they're a shortcut that breaks relational integrity and doesn't scale.

  • So if I can bind to the Recort Type Directly what is the need for creating a constant (which binds to the record type anyway)?

    a!dropdownField(
     label: 'Order Status',
     labelPosition: "ABOVE", 
     placeholder: "Select an Order status",
     searchDisplay: "AUTO",
     required: true,
     marginAbove: "LESS",
     data: 'recordType!JS Order Status',
     choiceLabels: 'recordType!JS Order Status.fields.name',
     choiceValues: 'recordType!JS Order Status.fields.statusId',
     value: ri!order['recordType!JS Order.fields.statusId'],
     saveInto: ri!order['recordType!JS Order.fields.statusId']
    ),

    From a database design perspective using the Record Type (Order Status) which has a relation to Order feels like the correct way to handle this scenario but creating a CONS which now binds to the Record Type just feels like an unnessesary step.

    Still not sure why to use the constant because it seems like additional work which does not carry any additional benefits. The take away for me here is when you want to bind a dropdownlist directly to a record type or to a constant (pointing to the same record type is the same)

    In code:


    a!dropdownField(
    label: "Training Category",
    labelPosition: "ABOVE",
    placeholder: "Select a training category",
    searchDisplay: "AUTO",
    required: true,
    marginAbove: "LESS",
    data: 'recordType!JT_W0114_TT Training Category', /* record type */
    choiceLabels: 'recordType!JT_W0114_TT Training Category.fields.VALUE',
    choiceValues: 'recordType!JT_W0114_TT Training Category.fields.CATEGORY_ID',
    value: ri!trainingResource['recordType!JT_W0114_TT Training Resource.fields.CATEGORY_ID'],
    saveInto: ri!trainingResource['recordType!JT_W0114_TT Training Resource.fields.CATEGORY_ID']
    ),
    a!dropdownField(
    label: "Training Category (Cons)",
    labelPosition: "ABOVE",
    placeholder: "Select a training category",
    searchDisplay: "AUTO",
    required: true,
    marginAbove: "LESS",
    data: cons!JT_W0114_TT_CONS_TRAINING_CATEGORY, /* Constant referencing record type */
    choiceLabels: 'recordType!JT_W0114_TT Training Category.fields.VALUE',
    choiceValues: 'recordType!JT_W0114_TT Training Category.fields.CATEGORY_ID',
    value: ri!trainingResource['recordType!JT_W0114_TT Training Resource.fields.CATEGORY_ID'],
    saveInto: ri!trainingResource['recordType!JT_W0114_TT Training Resource.fields.CATEGORY_ID']
    )

    Thanks everyone for the explanations.