Send email notification to Parent ticket owner when child task state changed to 'Pending Validation'

denu
Kilo Expert

I wanted to send email notification to parent ticket owner(Assigned to) when child ticket state changed to 'Pending Validation' from 'Working Progress'.   Can someone please advice me how to do this?

find_real_file.png

1 ACCEPTED SOLUTION

nitin_kumar
Mega Guru

1. Create an Event.


2. Write a Business rule on the child table, such that the created event gets triggered when the state changes to Pending Validation. Pass the parent ticket owner(can be retrieved via dot walking) as parm1 while triggering the event.


gs.eventQueue("name of the event", current, parent owner sys_id);


3. Create a notification and send it when the newly created event is triggered and send the notification to event parm1 (tick the checkbox).



If confused use this as reference -   Events and Email Notification - ServiceNow Wiki



Thanks,


Nitin



PS : Mark the answer as Like, Helpful or Correct based on the impact


View solution in original post

8 REPLIES 8

anurag92
Kilo Sage

Yes, you can create a notification on incident table and then set the condition as 'state changes to Pending Validation' and Parent is not empty.



Also, in Whom to Send, you can specify the recipient as 'parent.assigned_to'.



Let me know if this works.


nitin_kumar
Mega Guru

1. Create an Event.


2. Write a Business rule on the child table, such that the created event gets triggered when the state changes to Pending Validation. Pass the parent ticket owner(can be retrieved via dot walking) as parm1 while triggering the event.


gs.eventQueue("name of the event", current, parent owner sys_id);


3. Create a notification and send it when the newly created event is triggered and send the notification to event parm1 (tick the checkbox).



If confused use this as reference -   Events and Email Notification - ServiceNow Wiki



Thanks,


Nitin



PS : Mark the answer as Like, Helpful or Correct based on the impact


Thanks Nitin,



I still don't have any success.



1) Created an event 'pending.validation'


2) Created 'after' business rule and ticked on 'update' check box to trigger an event after record updated and pass the value to parm1 and parm2


3) Event based notification created to capture the event and fire emails



My problem is now this business rule is not even firing event at all when state of the child record changed to 'Pending Validation', checked the logs in the 'Event logs', but can not see any event happened when the record state changed.



This is the business rule which I created as per the instruction in wiki, not sure what's wrong with it. Could you please check it and let me know?.



Business Rule

if (current.state.changes() && current.state == -42) {


//gs.log('DS: Observation Number = ' + source.number +' Observation assigned to is ' + source.assigned_to.getDisplayValue());


  gs.eventQueue("pending.validation", current, assigned_to.email, assigned_to.getDisplayValue());


}



find_real_file.png


Hi Denu,


You are not passing the parm1 and parm 2 values properly. If you want to send the mail to the assigned_to of the parent record, you have to dotwalk to the assigned_to of the parent from the child record and you don't need to pass the mail id but the user id.



gs.eventQueue('pending.validation', current, current.parent.assigned_to, current.parent.assigned_to.getDisplayValue()); //replace parent with the field that is referencing the parent table.



And also instead of building the condition inside the script, you can also build the condition in the 'When to Run Section' - 'State Changes to Pending validation.'



Thanks,


Nitin.



PS : Mark the answer as Like, Helpful or Correct based on the impact