need to users direct groups

Team,

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

Regards,

Gaurav

  Discussion posts and replies are publicly visible

  • 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