Sorting Record Dataset

Certified Senior Developer

Is there a way to sort a record dataset after it's been queried? I have a list of records I got from a queryRecordType stored in a local variable that I am using in multiple places on an interface. I only want the record dataset to be sorted in a particular way for only one instance on the interface, but I want to leave it alone in all other instances, so I don't want to sort the data set within the initial queryRecordType call in the local variable. The only solution I've thought of is query the record again but this time sort it the way I want and store it in a new local variable or write my own expression rule to be able to sort records. I am not allowed to install plug-ins on my environment by the way.

Thanks!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Use to todatasubset() function to sort your data stored in local variables.

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    I've tried it this way and it is not working:

    local!test is a list of records, and I tried to sort on the field "value" as seen above which did not sort the records. I also tried sorting on the field but I called it as a record (recordtype!record.field.value) and it gave me an error:

    Not too sure if I did it correctly or not, so any help would be appreciated!

  • 0
    Certified Lead Developer
    in reply to kl0001

    That's interesting. , is that the expected behaviour? I could easily replicate this using the built in user record.

    a!localVariables(
      local!records: {
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Hans"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Otto"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Jack"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Hermine"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Susi"),
      },
      todatasubset(
        local!records,
        a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: 'recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName',
            ascending: true
          )
        )
      )
    )

Reply
  • 0
    Certified Lead Developer
    in reply to kl0001

    That's interesting. , is that the expected behaviour? I could easily replicate this using the built in user record.

    a!localVariables(
      local!records: {
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Hans"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Otto"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Jack"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Hermine"),
        'recordType!{SYSTEM_RECORD_TYPE_USER}User'('recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName': "Susi"),
      },
      todatasubset(
        local!records,
        a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: 'recordType!{SYSTEM_RECORD_TYPE_USER}User.fields.{SYSTEM_RECORD_TYPE_USER_FIELD_firstName}firstName',
            ascending: true
          )
        )
      )
    )

Children