add/remove users from a group based on user criteria

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 01:34 AM
Hi,
I have a requirement to assign a role to users who are part of a user Criteria and I need to update this dynamiclly.
My thinking as as follows:
- Create the user criteria
- create the role
- create a group and assign the role to the group
- create a job that would run on a daily basis, search for all the users who are part of the user criteria and not part of the group and add them to the group, search of any group members who are not part of the user criteria anymore and remove them from the group
If anyone has a better idea of how to achieve this with more configuration and less scripting I would be happy for ideas

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 01:42 AM
Hi there,
Have you considered a Scheduled Flow with zero script involved?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 02:41 AM
yes, if I can do it in a flow it could be better than a script. just not sure I have an OOTb way to identify if a user if part of a user criteria from a flow easily. although I guess I can always create an action for this or just add osme code within this specific action.
was hoping for something even more "OOTB" that does this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 08:44 AM
Hi @User504760 :
I stumbled upon similar use cases to automate knowledge_role to be added to user-matching certain criteria unfortunately we don't have an easy OOB way to do i had to implemented a custom solution with OOB guidlience i followed hope this is helpful to you too.
We have a feature somewhat similar implemented using condition builder and role in OOB HRSD feature called "Client Role Rule - Which in the background runs as a BR on HR Profile insert" - it checks the condition used on the condition column. It adds the role to the HR profile user which matches them.
I mimicked the same but instead of a condition builder I used a gilde_list to user criteria and reference OOB Script includes "UserCriteriaDiagnosticsUtil" and undocumented API Util "UserCriteriaLoader"
Usefull Community link of few method of UserCriteriaLoader : https://www.servicenow.com/community/developer-blog/usercriterialoader-api-to-evaluate-user-criteria...
Mark this as Helpful / Accept the Solution if this clears your issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 10:32 AM
looks like we will need to do something custom but this is very helpful. thanks 🙂