When dealing with a Person/Group SharePoint column that allows multiple selections or the selection of both people and groups, retrieving and processing the data can become more complex. Here's an explanation of why this is needed and how to handle it:
1. Person/Group Column with Multiple Selections:
- When the column allows selecting multiple people or groups, SharePoint stores the selected values as an array of user or group IDs. Since it's not a single ID, you need to iterate through this array to get each person or group's details, such as email and name.
- For each user or group ID in the array, perform the necessary API call to _api/web/getuserbyid or _api/web/siteusers/getbyid. Use a loop or collection operation in Nintex Automation Cloud to process each ID one by one.
2. Person/Group Column Allowing Both People and Groups:
- If both users and groups can be selected in the column, the returned data may contain both types of IDs. Since users and groups have different attributes, you must handle them separately. For example, a user will have an email address, but a group may not.
- For users, use expressions like $['d']['Email'] to extract the email and $['d']['Title'] to extract the name. For groups, other fields may need to be queried, such as the group name or its members.
3. Person/Group Column with Multiple Selections and Both People and Groups:
- This scenario is the most complicated, as the column may contain a mixture of users and groups. You need to process this data by iterating over the entries and determining whether each one is a user or a group before making the appropriate API call.
Step-by-Step Implementation:
Use the "Apply a Regular Expression" Action
The first step is to extract the SharePoint IDs using a regular expression. This action allows you to parse a string of data containing user and group IDs and split them into individual items in a collection. The "Split" operator is used here to convert the list of IDs into a collection.
- Action: Apply Regular Expression
- Pattern: Use a suitable regex to extract the IDs.
- Operator: Split
- Output: Add all the parsed IDs to a collection variable for looping.
2. Loop Through the Collection
Once the IDs are in a collection, use the For Each loop to iterate over each item. Each ID will either represent a SharePoint user or a SharePoint group. The automation needs to handle both types of objects simultaneously.
- Action: Loop (For Each)
- Input Collection: The collection of IDs obtained from the regular expression.
- Output: Process each ID within the loop.
3. Retrieve Users and Groups Using SharePoint Web Services
Within the loop, add a Parallel Path action to run two SharePoint web service calls at the same time—one to get users and the other to get groups.
- Path 1: Retrieve User Information
- URL: YourSharePointSite/_api/web/getuserbyid(Current Item from the loop)
- Output: Store the response object containing user details.
- Path 2: Retrieve Group Information
- URL: YourSharePointSite/_api/web/sitegroups/GetById(Current Item from the loop)
- Output: Store the response object containing group details.
Both actions will return an object that either contains user information (email) or group details (group name).
4. Query the JSON Response
Once the SharePoint web service calls return a result, the next step is to extract the specific user or group data using the Query JSON action.
- User JSONPath Expression: $['d']['Email'] – Retrieves the email if the ID is for a user.
- Group JSONPath Expression: $['d']['Title'] – Retrieves the group name if the ID is for a group.
If the object corresponds to a user, the group variable will be empty, and vice versa.
5. Run If Condition to Check Variables
Now, add a Run If True action to check if the extracted variable (user email or group name) is populated. This helps ensure that you correctly identify whether the current ID represents a user or a group.
- Condition: Check if the variable (either user or group) is not empty.
For User

For Group

6. Add Users and Groups to Separate Collections
Finally, for proper organization, add the extracted user emails and group names into their respective collections. This action allows you to maintain two separate collections—one for all users and another for all groups.
- Action: Add each user email or group name to their respective collections.
For User

For Group
