Group a record list by date

Certified Associate Developer

Hello, 
I'm currently building an audit history for my job. The way our client wants the history displayed is grouped by the date that the history action is created on. So that the list sometimes displays 1 action per timestamp and sometimes 2 or 3 actions by timestamp. We have found a way to do this but it is complicated. I get all the values in the histActionOn, then I uses union() to get only the unique values. From this point I can do more complex indexing to organize all the actions by date, or I can throw a a!queryRecordType() in a for loop and filter it by the histActionOn field. This gets exactly what I need. A record list with actions separated by date and time, but it's incredibly inefficient as it puts a query in a for loop. I'm sure there's a way to group all the actions by unique dates, but I don't know a way at this point. 

Any thoughts?

Thank you

Jason

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to Peter Lewis

    Yes, I want to aggregate everything under the unique dates that cations were taken. Essentially I want the modifiedDate field to be a sort of pk in which all records are organized under that date. While Appian does allow me to aggregate based on the date I want, I can't condense the data so that all records that happen on one date, are nested under that one unique date. At least, I can't seem to do this without indexing and using wherecontains() and all that. 

    example:
    i query a record type and get only the date fields
    {dateAndTime1, dateAndTime2, dateAndTime3, dateAndTime4, dateAndTime4}

    I apply union() to eliminate duplicates resulting in {dateAndTime1, dateAndTime2, dateAndTime3, dateAndTime4}

    I then take that list and use index to aggregate all the records under those dates:

    forEach(
        items: local!uniqeDates,
        expression: index(local!recordQuery, wherecontains(fv!item, local!recordQuery.modifiedDate))
    ),

    which outputs something like:

        uniquedate1
                 record
        uniquedate2
                 record
        uniquedate3
                 record
        uniquedate4
                 record
                 record


    uniqueDate4 has two records because two modifications were made at that exact date and time. 


    again, I am able to produce what I want, I just want to know if there is an easier way to do this using built in functionality for record types. 

  • 0
    Appian Employee
    in reply to Jason

    Ahhhh I see what you mean - the key is that you still want to keep the list of the original data that you are grouping by. Unfortunately I'm not sure there's another way that is that much better - I think the approach you mentioned is probably the right way.