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.

stop email notifications when assigning incident to myself

kurt_englund
Kilo Explorer

I'm trying to setup outbound emails to only send out emails if another user assigns the ticket.

Example: If a service desk tech assigns themselves an incident. No email
                                If a manager/or other service desk tech assigns an incident to a different tech. Send email


My current script now is:

current.sys_updated_by!=current.assigned_to;

8 REPLIES 8

ghsrikanth
Tera Guru

Write an after Business rule on the table


With the condition -


curent.assigned_to.changes() && !gs.nil(current.assigned_to) && current.assigned_to != gs.getUserID()



In the script section -


gs.eventQueue('notify_incident.assignment', current, current.assigned_to, '');



In the notification, make sure you uncheck Send to event creater checkbox



Mark if it is helpful or correct, feedback is appreciated


When I created this business rule I was getting an error when testing.





The error said " curent.assigned_to.changes() && !gs.nil(current.assigned_to) && current.assigned_to != gs.getUserID() Skipping business rule"



Thank you for your feed back and please let me know if   there is anything else I can try.


Could you please remove the condition field instead bring those inside the script to print it out -


want to debug what values its being returned -



Clear off the condition field (so this BR will trigger)


In script, print the values


gs.log('Assigned to changes: ' + current.assigned_to.changes(), 'debugBusinessrule');


gs.log('Assigned to NULL or NOT: ' + !gs.nil(current.assigned_to), 'debugBusinessrule');


gs.log('Current Assigned to: ' + current.assigned_to, 'debugBusinessrule');



Assign the incident to you and please check the log statements, is it coming as expected or not


HV1
Mega Guru

You can filter your notification as:



Screen Shot 2016-03-22 at 9.58.09 AM.png



- Hardik Vora