Send email to previous Assigned to when Assigned to changes

Bogdan18
Tera Guru

Hi everyone,

I have to create an email notification based on the Incident table with the following conditions:

        - if the existing Assigned to person from the same support group changes then an email needs to be firing and send a notification to the previous Assigned to telling him that he is no longer the Assigned to person on that incident

So if X from the Smart Support Assignment group for example is the current Assigned to person and Y from the same support group is replacing X with him and assigns himself on the incident as he Assigned to person then an email needs to be sent to X telling him that he is no longer the Assigned to person for that incident.

I have tried to get this done through an email notification but I don't see anywhere in the "Who will receive" tab a option to specify that the email needs to be sent to the previous Assigned to person.

Does anybody know how to accomplish this?

Thank you,

Bogdan

1 ACCEPTED SOLUTION

Brian Dailey1
Kilo Sage

Hi Bogdan,



I believe the solution for you is in two parts:   1) create an event for yourself by Business Rule, and 2) create a Notification that fires on the new event.



You can reference the previous values of a record within a before/after business rule, but I don't think you can reference previous from within the script on a Notification itself.   So you'll have to do the BR to capture your info and the Notification to respond to it.



Here is how I'd approach this solution:



  1. For your Business Rule:
    1. check the Advanced box
    2. in the condition field, enter:
      current.assigned_to.changes() && (current.assigned_to.u_default_group.sys_id == previous.assigned_to.u_default_group.sys_id)
    3. for When to Run, select "After" and "Update"
    4. in the script, enter:
      function onAfter(current, previous) {
            //This function will be automatically called when this rule is processed.
            gs.eventQueue("incident.reassigned", current, current.assigned_to.sys_id , previous.assigned_to.sys_id);
      }

    5. Register your new event (Event Registry - ServiceNow Wiki) as "incident.reassigned"
  2. For your Notification:
    1. Choose Send when: "Event is fired"
    2. On "When to send", Select your new event as the Event name
    3. On "Who will receive", Select the "Event parm 2 contains recipient" checkbox
    4. Fill out the rest of your notification as normal to let the person know they no longer have the ticket.




Good luck,


-Brian




Edit:   What Ravi said... but with more words.  


View solution in original post

8 REPLIES 8

Brian_Pluff
Giga Contributor

Maybe you could create a new field on the inc table that stores the previous 'Assigned To' user, have it get updated through a business rule whenever the 'Assigned To' changes.   This would give you a filed to use for the e-mail notification.


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

You can trigger an event when it happens and put the "old assignee" as value when you create it, then you can trigger a notification with that.



Let me know if you get stuck.



//Göran


Ravi Prasad1
Tera Guru

Pass old assignee as a parameter using business rule while triggering the event.


Brian Dailey1
Kilo Sage

Hi Bogdan,



I believe the solution for you is in two parts:   1) create an event for yourself by Business Rule, and 2) create a Notification that fires on the new event.



You can reference the previous values of a record within a before/after business rule, but I don't think you can reference previous from within the script on a Notification itself.   So you'll have to do the BR to capture your info and the Notification to respond to it.



Here is how I'd approach this solution:



  1. For your Business Rule:
    1. check the Advanced box
    2. in the condition field, enter:
      current.assigned_to.changes() && (current.assigned_to.u_default_group.sys_id == previous.assigned_to.u_default_group.sys_id)
    3. for When to Run, select "After" and "Update"
    4. in the script, enter:
      function onAfter(current, previous) {
            //This function will be automatically called when this rule is processed.
            gs.eventQueue("incident.reassigned", current, current.assigned_to.sys_id , previous.assigned_to.sys_id);
      }

    5. Register your new event (Event Registry - ServiceNow Wiki) as "incident.reassigned"
  2. For your Notification:
    1. Choose Send when: "Event is fired"
    2. On "When to send", Select your new event as the Event name
    3. On "Who will receive", Select the "Event parm 2 contains recipient" checkbox
    4. Fill out the rest of your notification as normal to let the person know they no longer have the ticket.




Good luck,


-Brian




Edit:   What Ravi said... but with more words.