- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 02:36 PM
Hi,
When using the Microsoft AD Spoke, Lookup User action in Flow Designer, I set the property list to return the user's groups from AD. The attribute in AD is MemberOf.
The lookup is working and I retrieve the user's memberof groups in a JSON String. This string can't be used in a for each loop, so I created a custom action to parse the JSON string. However, I am having a hard time.
Some users are only in 1 group, so the JSON looks like this.
{
"MemberOf":"CN=Bright Executives,OU=SNOW,OU=Groups,OU=Connected,DC=Dev,DC=Green,DC=com"
}
Then there are some that have multiple groups and this is how the return looks.
{
"MemberOf":
[
"CN=Group_22c6,OU=MGroups,OU=Groups,OU=Resources,OU=Context,DC=Green,DC=com",
"CN=Bright Executives,OU=SNOW,OU=Groups,OU=Connected,DC=Dev,DC=Green,DC=com"
]
}
I tried to use the Parser step action in flow, but it is based on a structure and either option doesn't fit the other. I even tried just coding it directly in a script but my return looks like this.
CN=Group_22c6,OU=MGroups,OU=Groups,OU=Resources,OU=Context,DC=Green,DC=com,CN=Bright Executives,OU=SNOW,OU=Groups,OU=Connected,DC=Dev,DC=Green,DC=com
If I tried to turn this into an array, it would loop through all the items, separated by comma. That could get long especially if they have more than 10 groups.
Because when you return groups from Active Directory, it returns as the distinguishedname and not just the display name. The real information that I need from these are the CN= text.
I need to be able to push the items into an array, no matter if it is just 1 group or multiple so that I can use the foreach loop.
Does anyone have any ideas, how I can go about this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 12:47 AM
@Dazler Tried and tested solution. Parse it using the code
Result 2 (when user is part of multiple group):
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 01:10 PM
Dazler, how are you getting the JSON input? OOB it's a array.string when calling Look Up User