How to Send Email notifications when Change Task is inserted and Assigned to a user

humblecommitted
Kilo Guru

Hello Everyone,

I wanted to ask the community how to send out notifications when a change task has been assigned to a user.

Please let me know.

1 ACCEPTED SOLUTION

Business rule:



find_real_file.png



Notification (Top of form and when to send):



find_real_file.png



Notification (who will receive):



find_real_file.png


Note: We don't send ours to the event creator.   If you assign a change task to yourself, you probably don't need an email telling you that you did.   We also decided that using an event parameter as the recipient wasn't necessary.



Notification (what it will contain):



find_real_file.png



Below is a video of this all working together to make an email when a change task is assigned to a user:





If you're still not successful after this (like if the notification still says "Record inserted or updated" instead of "Event is fired"), that sounds like an issue with the ui policies on the notification page.   Try toggling between Default and Advanced view to see if that makes a difference.   Otherwise, this is as far as I can help you, and you'll need to get ServiceNow support involved directly.


View solution in original post

12 REPLIES 12

jbauguess
Tera Expert

There are two main ways to do this:



1. Create a notification record on the change_task table that triggers when the assigned to changes and isn't empty.



2. Create a business rule on the change_task table that triggers an event when the assigned to changes and isn't empty, and create a notification that triggers on that event.



I prefer option 2, because I unit test my events (well, I unit test the script include that I use in my business rule and also ensure the event itself fired).   Option 1 is a lot easier to implement at first.



You can find a lot more detailed information here: Email Notifications - ServiceNow Wiki


Hello Justin,



I am trying the first method since it seemed like it would be the quickest solution.   However, it does not seem to work. Screen Shots provided below:


I have tried setting the send when to Record inserted or updated, and fired on event.


find_real_file.png


but nothing gets sent out or logged in the event logs:


find_real_file.png


find_real_file.png



Any recommendations?



For the Business Rule, do you have an example code to query this table update to create the event log item?



Thanks in advanced.


Thanks for the screen shots. Very helpful, albeit somewhat confusing. If you select "Record is inserted or update", then the event name should not be present. The two are mutually exclusive. Similarly, if you select Event is fired, then insert/update disappear.



Your condition looks good. If you're not using the event method, then you are not likely to see an event triggered. Check the System Mailboxes (particularly Outbox, and Sent.) You can also try the "Preview Notification" button to run a sample test to see if/when/how it will be sent. This is useful for debugging also.


Hello everyone,



I am trying the following step #2 suggested from Justin:



Created the Business Rule with the following code


find_real_file.png


var myUserObject = gs.getUser();


  if (gs.nil(current.assigned_to)){   //we are checking if the work_start is empty or not  


  gs.eventQueue("change.task.not.assigned", current, gs.work_start(), myUserObject.getDisplayName());      


  } else {          


  gs.eventQueue("change.task.assigned", current, gs.work_start(), myUserObject.getDisplayName());      


  }




Created an event name in the registry


find_real_file.png


Created the notification for the event item


find_real_file.png


find_real_file.png


also tried to set the "send when" to "Record inserted or updated"


find_real_file.png



and I noticed when I try to check mark "event parm 2 contains recipient" it doesnt stay saved:


find_real_file.png



When I try creating a change task, it creates the event but doesnt send an email to who the change task is assigned to:


find_real_file.png



find_real_file.png


find_real_file.png



The assigned to person has an associated email address on their sys_user table.



Any help would greatly be appreciated.