How to sort complex list

Certified Associate Developer

Hello, 

How I can sort this by ClientName ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Are you querying this from a database via a QueryEntity rule? If so, you can easily sort on a particular field via your a!pagingInfo() definition.

    If it's data you have inherent or manually-created in an interface or a rule, then it takes a bit more work.  Appian has no direct way to do this but a fairly easy indirect workaround, again involving pagingInfo.

    a!localVariables(
      local!dictionary: {
        {
          clientId: 1,
          clientName: "z client 1"
        },
        {
          clientId: 32,
          clientName: "a client name"
        },
        {
          clientId: 58,
          clientName: "middle client"
        }
      },
      
      todatasubset(
        local!dictionary,
        a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: "clientName",
            ascending: true()
          )
        )
      ).data
    )

Reply
  • 0
    Certified Lead Developer

    Are you querying this from a database via a QueryEntity rule? If so, you can easily sort on a particular field via your a!pagingInfo() definition.

    If it's data you have inherent or manually-created in an interface or a rule, then it takes a bit more work.  Appian has no direct way to do this but a fairly easy indirect workaround, again involving pagingInfo.

    a!localVariables(
      local!dictionary: {
        {
          clientId: 1,
          clientName: "z client 1"
        },
        {
          clientId: 32,
          clientName: "a client name"
        },
        {
          clientId: 58,
          clientName: "middle client"
        }
      },
      
      todatasubset(
        local!dictionary,
        a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: "clientName",
            ascending: true()
          )
        )
      ).data
    )

Children