Is there a way to sort users by their first or last names instead of their user Ids?

Certified Associate Developer

Is there a way to sort users by their first or last names on reports instead of their user Ids?
Whenever I try to convert a user into text to display via user(pv!user, 'firstName') the data returns blank....

OriginalPostID-32617

  Discussion posts and replies are publicly visible

Parents
  • This will solve the problem, but it doesn't scale too well for sorting large numbers of users (>150).

    =a!localVariables(
      local!datasubset: todatasubset(
        arrayToPage: a!forEach(
          items: ri!users,
          expression: {
            username: tostring(fv!item),
            firstName: if(ri!sortBy = "firstName",user(fv!item,"firstName"),""),
            lastName: if(ri!sortBy = "lastName",user(fv!item,"lastName"),"")
          }
        ),
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: ri!sortBy,
            ascending: ri!ascending
          )
        )
      ),
      touser(index(local!datasubset.data,"username"))
    )
     

Reply
  • This will solve the problem, but it doesn't scale too well for sorting large numbers of users (>150).

    =a!localVariables(
      local!datasubset: todatasubset(
        arrayToPage: a!forEach(
          items: ri!users,
          expression: {
            username: tostring(fv!item),
            firstName: if(ri!sortBy = "firstName",user(fv!item,"firstName"),""),
            lastName: if(ri!sortBy = "lastName",user(fv!item,"lastName"),"")
          }
        ),
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: ri!sortBy,
            ascending: ri!ascending
          )
        )
      ),
      touser(index(local!datasubset.data,"username"))
    )
     

Children
No Data