We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

BrianD502676804
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

Hi Brian,



This is an interesting thread which kicked off with a interesting question.



I was wondering however about the u_default_group in the condition field you refer to.


Am I missing something or is this unexplained?



Best Regards



Tony




Hi Tony,



It's a mystery...



No, that is a custom field we've added to [sys_user] for various uses (automatic assignments by category, notifications, etc.).   I hadn't thought about that in my earlier post...   A regular Joe (such as yourself) would need to adjust that condition to something like:



        current.assigned_to.changes() && (current.assignment_group.sys_id == previous.assignment_group.sys_id)



The rest of that solution should play out the same, though.




Good catch.


-Brian


Hi Brian,



Thank you for taking the time to detail the solution, it worked perfectly.



Thanks,


Bogdan


Glad to hear it.



-Brian