Skip to main content
August 12, 2021
Question

need to users direct groups

  • August 12, 2021
  • 1 reply
  • 0 views

Team,

We have list of users in array , we want to know there direct group names which they belongs too.

Regards,

Gaurav

    1 reply

    harshitb6843
    August 12, 2021

    Hi there,

    I couldn't think of any direct way and I am not aware of a plug-in also (other community members might help) for this but I have found a workaround. 
    Attaching a code snippet below. 

    a!localVariables(
      local!user: loggedInUser(),
      local!userGroups: getgroupsformemberuser(local!user),
      local!booleanFlags: a!forEach(
        items: local!userGroups,
        expression: contains(
          touniformstring(a!groupMembers(
            group: fv!item,
            direct: true,
            memberType: "USER"
          ).data),
          tostring(local!user)
        )
      ),
      index(
        local!userGroups,
        wherecontains(
          true,
          local!booleanFlags
        ),
        null
      )
    )

    It will give you all the direct groups of the passed user. 

    Thanks,
    Harshit Bumb