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

Our instance is setup up to create incidents based off of emails. So Opened by will always show up as the Callers user_ID.


In that case, your initial condition mentioned just needs to be changed to:


current.sys_updated_by != current.assigned_to.user_name



- Hardik Vora


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Kurt,



"sys_updated_by" is a string field which stores the user_id field from the sys-user table. However "assigned_to" is a reference field which pulls the sys_id(current.assigned_to).


Hence in this case you need to dot-walking to the assigned_to field to pull the user_id and then compare i.e current.assigned_to.user_name



Please let us know if you have any questions.


Volente_
Kilo Expert

Hi there Kurt, 

 

It looks like you did not get an answer to this question. In order to accomplish your goal to not have a notification distributed when a person is assigning a ticket to themselves you would need to: 

- Navigate to the desired notification itself. (System notification > email > notifications) 

- Under related links click on "advanced view" 

- Under the "when to send" tab replicate the following: 

find_real_file.png

***It is important to note that you need the gs.getUserID() function/method specifically when attempting to access the GlideSystem user object in this case as this returns the sys_id string value for the currently logged-in user and as Pradeep mentioned above, the assigned_to field is a reference field which pulls the sys_id (current.assigned_to).

 

A great resource on the GlideSystem User Object can be found here: https://www.servicenowguru.com/scripting/user-object-cheat-sheet/

Resources on advanced conditions for email notifications can be found here: https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/notification/task/t_Cr... and https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/notification/concept/c...