add/remove users from a group based on user criteria

User504760
ServiceNow Employee
ServiceNow Employee

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

5 REPLIES 5

Josh Pirozzi
Kilo Sage

Hi @User504760,

 

Would you be creating new groups / roles on a regular basis, or are you working on assigning users to a Group based on the User Criteria?

 

Is this User Criteria auto-assigned from your HR (ERP) platform and can be mapped to fields on each sys_user record?

 

If yes, you should be able to do a scheduled Flow where you:

  • Query (look up records) where the sys_user has XX criteria being true
  • For each where the sysid matches the sys_user with XX criteria being true, then look up the Group(s) and create the sys_user_grmember record on that group.