Background Script - to remove roles from users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 06:37 AM
Hi,
I need assistance to remove a role from multiple users. I have got a list of the users that need to retain the role, but I don't have an option of "is not one of" to build a query for an encoded list.
any recommendation on the best way?
Thanks,
L
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 08:37 AM
Hi,
Ideally speaking there should not be any record in that table with user as NULL or empty
but still if you want to add that extra check
please update as below
gr.addQuery('user.sys_id', 'NOT IN', arr);
gr.addEncodedQuery('user=NULL');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader