Why calculated columns of a RecordType are not available in the Fields object ?

Certified Senior Developer

Hi,

I've created a simple RecordType based on a MySQL table, and when editing the grid list (tab List), I have added a new column that does not exist is the underlying table (ex : "total" that is the sum of fields "nb1" and "nb2"). 

When using this colum in a Grid of an interface, why does the "Recordtype!Vehicles.Fields.total" is not available ? 

Does the Fields object contain only the fields that exist in the underlying table ?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I think that may be so.  Thankfully, you can find two very quick ways around it:

    1. Recreate that table with the total row in a View designed to be read directly by Appian.  It's actually a very common design pattern, well worth looking into, that you write according to tables, but you receive data from your DB exclusively in terms of Views.  The "always query from Views" pattern.  This allows you to get optimum database structure without having to make your tables conform to your CDTs.  You can make your VIEWs conform to your CDTs.

    2.  Recreate the logic (as painful as it might be to repeat yourself) in Appian code.  You have access to all manner of query aggregation functions including SUM that you can use in your query expression.  You also have the benefit of a "total" column that you can compare against your Appian to make sure it's right. (You might want an explicit note in a comment that this rule DOES NOT read the database's "total" but makes its own.)

  • 0
    Certified Senior Developer
    in reply to Dave Lewis

    Thank you David.

    For our customer projects, our calculated fields are effectively always added in a new MySql view.

    But my question, was just an example of adding a new column in a RecordType. That's all ;-)

    So I just need to know : the "RecordField.fields" object can only displays the fields that is in the DB table (or DB view)? not all the columns ?