Business Rule for Checking Requester Role and Add them into Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:13 PM
Hi all,
I am totally new to ServiceNow administration and I bump into a request that I need some help here.
The requirement is as per below:
1. whenever there is a new policy exception created, check if the requester have sn_grc.business_user role.
2. if yes, then do nothing.
3. if no, then add the 'GRC Business User' group to the user.
I tried various script and it still does not work and hoping to get some guidance here.
Appreciate the advice/guidance from this community.
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:43 PM - edited 10-10-2023 07:19 PM
Hi @butterDream16 try the below script. Assuming you script is on RITM table
var requestedForSysID = current.request.requested_for; // get requestedfor sysid
var userObject = gs.getUser().getUserByID(requestedForSysID);
if (userObject.hasRole('n_grc.business_user')) { // check user has role
return 'yes';
}
else{ // add user to group
var grp = new GlideRecord('sys_user_grmember');
grp.initialize();
grp.user = requestedForSysID;
grp.group= 'sysID of grp';
grp.insert();
}
Harish