Background Script - to remove roles from users

Lucy10
Tera Contributor

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

5 REPLIES 5

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader