Custom record field query

Certified Associate Developer

Hi,

I have created one custom record field where it calculated sum of all the event points present in the table.But I'm trying to display this data in the grid based on the date range selection so basically if that date range has only one row with event point = 10, it should display only row with value 10 but it is displaying the sum of all 100 rows in a single row. How to handle single row data calculation in appian records?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    As mentioned, custom record fields do not support live query filters. Their logic is static.

    I have done this type of thing before, but it's a bit weird to set up.

    The core conundrum: to perform an aggregation without limitations on the total rows in a relationship, a!aggregationFields() in a!queryRecordType() works really well since you can setup groupings and measures. But read-only record grids don't support a!aggregationFields in their fields inputs.

    A technical workaround is to put a!queryRecordByIdentifier() with a!aggregationFields() on each row of your data (or sum() with an embedded query). If the number of rows in your grid is small, and your dataset is small, you can get away with this in theory. However, there are severe performance issues in non-ideal conditions. Querying data in each row of a grid is an anti-pattern, breaks many best practices, and is not recommended in any production environment.

    The trick (with caveats) is sync'ing the record grid with a separate single query that leverages a!aggregationFields with groupings on appropriate identifiers. Then your record grid can perform an index/wherecontains into your single query based upon row identifiers that match the grouping id's of the query. The pagingInfo of the grid can be saved it into a local variable for use by the query. However, record grids do not expose the selected record filters* for use by other Appian components. So for that to work, the grid filters need to be managed as UI objects separately - i.e. it really is a pain to deal with.

    This a gap that Appian might be able to solve, one day, with enough pressure from customers. It's a fairly common use case for small reporting dashboards and task management queues.

    *technically-speaking, there are some 'tricks' to get the filters, but I wouldn't recommend them.

Reply
  • 0
    Certified Lead Developer

    As mentioned, custom record fields do not support live query filters. Their logic is static.

    I have done this type of thing before, but it's a bit weird to set up.

    The core conundrum: to perform an aggregation without limitations on the total rows in a relationship, a!aggregationFields() in a!queryRecordType() works really well since you can setup groupings and measures. But read-only record grids don't support a!aggregationFields in their fields inputs.

    A technical workaround is to put a!queryRecordByIdentifier() with a!aggregationFields() on each row of your data (or sum() with an embedded query). If the number of rows in your grid is small, and your dataset is small, you can get away with this in theory. However, there are severe performance issues in non-ideal conditions. Querying data in each row of a grid is an anti-pattern, breaks many best practices, and is not recommended in any production environment.

    The trick (with caveats) is sync'ing the record grid with a separate single query that leverages a!aggregationFields with groupings on appropriate identifiers. Then your record grid can perform an index/wherecontains into your single query based upon row identifiers that match the grouping id's of the query. The pagingInfo of the grid can be saved it into a local variable for use by the query. However, record grids do not expose the selected record filters* for use by other Appian components. So for that to work, the grid filters need to be managed as UI objects separately - i.e. it really is a pain to deal with.

    This a gap that Appian might be able to solve, one day, with enough pressure from customers. It's a fairly common use case for small reporting dashboards and task management queues.

    *technically-speaking, there are some 'tricks' to get the filters, but I wouldn't recommend them.

Children
No Data