Sort appian group members for dropdown

Certified Senior Developer

Hi , How can I sort appian group members and bind to dropdown.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Where do you get this list from? The groupMembers() function can already sort your items.

  • When you provide paging info for groupMembers, you can additionally pass these two fields in the sortInfo and control the sorting. 

    a!groupMembers(
      group: cons!GROUP,
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 100,
        sort: {
          a!sortInfo(
          field: "groupName",
          ascending: true
        ),
        a!sortInfo(
          field: "username",
          ascending: true
        )
        }
      )
    ).data

  • 0
    Certified Senior Developer

    If you have a particular group then you can use the a!groupMembers() function. If its the users from the environment, you can use functions from plugins and create your dropDown. Using what Harshit has given as a sample code for a group Specific requirement.

    getAllUsers() is a function to get all the users from the environment. You can get it here People Functions Plug-in


    a!localVariables(
      local!users: getallusers(1, - 1),
      local!choices: a!forEach(
        items: local!users,
        expression: concat(
          user(fv!item, "firstName"),
          " ",
          user(fv!item, "lastName")
        ),
        
      ),
      a!dropdownField(
        choiceLabels: local!choices,
        choiceValues: local!users,
        placeholder: "Select User"
      )
    )



  • 0
    Certified Senior Developer
    in reply to Konduru Chaitanya

    Thank you all for your replies.

    This i need to add to record filter list. How can do that.

  • 0
    Certified Lead Developer
    in reply to ak0642

    You can just copy and paste this into your filter list, run a loop over it, and add the query filter.

    a!recordFilterList(
      name: "Members",
      options: a!forEach(
        items: a!groupMembers(
          group: cons!GROUP,
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: 100,
            sort: {
              a!sortInfo(
                field: "groupName",
                ascending: true
              ),
              a!sortInfo(
                field: "username",
                ascending: true
              )
            }
          )
        ).data,
        expression: a!recordFilterListOption(
          id: fv!index,
          name: fv!item,
          filter: a!queryFilter(
            field: recordType!Record.fields.fieldname,
            operator: "=",
            value: fv!item
          )
        )
      )
    )

  • 0
    Certified Senior Developer
    in reply to Harshit Bumb (Appyzie)

    Thank you. This is just giving me the group name, but the issue resolved with the code below.

    a!localVariables(
      local!assigneesDataSubset: todatasubset(
        arrayToPage: a!forEach(
          items: getdistinctusers(
            peopleArray: { cons }
          ),
          expression: {
            assignee: fv!item,
            assigneeName: rule!Exp_displayUserFirstLast(
              user: fv!item
            )
          }
        ),
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: -1,
          sort: a!sortInfo(
            field: "assigneeName",
            ascending: true()
          )
        )
      ),
      a!recordFilterList(
        name: "Assigned To",
        options: a!forEach(
          items: index(index(local!assigneesDataSubset,"data",{}),"assignee",{}),
          expression: a!recordFilterListOption(
            id: fv!index,
            name: index(index(local!assigneesDataSubset,"data",{}), fv!index, "-"),
            filter: a!queryFilter(
              field: Assignee record filed )}',
              operator: "=",
              value: fv!item
            )
          )
        )
      )
    )