Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send notification to manager if user role was removed

AnilM99
Tera Expert

Hi Team,

 

I have a requirement, If user ITIL role is removed send notification to user manager

 

Thanks!

3 REPLIES 3

SanjivMeher
Mega Patron
Mega Patron

You can create a business rule on delete on the table sys_user_has_role to trigger a notification.


Please mark this response as correct or helpful if it assisted you with your question.

Prince Arora
Tera Sage

@AnilM99 

 

All the user roles has been traced using table "sys_user_has_role" table, if we are providing/removing roles to the user, it will create/delete entries in that table

Steps:

1) Create a new Before - Delete Business rule as follows

PrinceArora_0-1700071233580.png

 

2) Create a event in the advance script trigger an event using gs.eventQueue()

3) Map an email notification with the event 

 

This will work 100%

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

 

AnilM99
Tera Expert

Hi Thanks for the replay,

The BR is working but notification is not triggering, 

Notification is created 'sys_user_has_role' table 
This is my script:
var manager = '';
gs.addInfoMessage("ITIL BR is Executed: "+current.user.manager.email);
manager += current.user.manager.email+',';
gs.eventQueue("sys_user.itil_role_change", current, manager);
 
})(current, previous);
 
Thanks!