Email notification sent to asigned to on task when req item comments updated

Sam Ogden
Tera Guru

Hi All,

I require that when the additional comments on the sc_req_item change an email notification is sent to the person who is assigned to the task related to that item.   I found an earlier post on here and tried to replicate the business rule and notification, but I'm not getting any email notification firing.   Below is the business rule setup and email notification setup.   Do I need to add somewhere to the notification the business rule that is being used?

I was also wondering if the sc_req_item has multiple tasks related to it, would this send a notification to the assigned to person on each task?

Any help as to where I've gone wrong is greatly appreciated.

Business Rule:

find_real_file.png

find_real_file.png

Email Notification

find_real_file.png.

find_real_file.png

find_real_file.png

find_real_file.png

Email Template

find_real_file.png

1 ACCEPTED SOLUTION

Hey Sam,



Sorry was caught up with my implementation specialist exam.



This is puzzling, the order of tasks shouldn't make any difference, can you please modify the BR as follows -



function executeRule(current, previous /*null when async*/) {


var email_to = [];
var sc_task = new GlideRecord('sc_task');
sc_task.addQuery('request_item',current.sys_id+'');
sc_task.addActiveQuery();                             //eliminates the inactive/closed tasks, optimizes the results
sc_task.query();
while (sc_task.next()){


  gs.log("sam1");
  if (sc_task.assigned_to == "" || sc_task.assigned_to == null){                 //included the null keyword as sometimes the system doesn't compare successfully with ""
                gs.log("sam2 "+sc_task.assignment_group.manager);


                email_to.push(sc_task.assignment_group.manager+'');
  }
  else{                                                                                                                                                                                                 //added an else to optimize the query
              gs.log("sam3 "+sc_task.assigned_to);


              email_to.push(sc_task.assigned_to+'');
  }
}


gs.log("sam4 "+email_to);
gs.eventQueue("sc_req_item.commented.itil", current, email_to.join(), gs.getUserName());


})(current, previous);




I've just tweaked the logs and the email_to.push statement.



Please run all the 4 use cases and share the logs/results:


1. both tasks have assigned to


2. both tasks don't have assigned to


3. task 1 has assigned to & task 2 doesn't


4. task 2 has assigned to & task 1 doesn't


View solution in original post

27 REPLIES 27

Hi Sakshi,



Thanks for the above.   I've just ran a couple of tests.



If both tasks the assigned_to is blank then both the groups managers get the email notification and the script log statements is :


find_real_file.png


If the first taks assigned_ to is blank, but the second task is assigned to an individual the first group manager gets an email and the individual in the second task gets and email.   The script log statement is:


find_real_file.png


If the first task is assigned to an individual, but the second task assigned_to is blank, the person assigned to the first taks gets an email, but the manager of the second task does not.   The script log statement is:


find_real_file.png



I hope this helps, but let me know if you need me to provide anything else.



Thanks once again.


Hi Sakshi,



Is the above helpful or do you require any further information?



Thanks


Sakshi14
Giga Expert

Hey Sam,



Sorry didn't realize this would still be a problem!



Have you tried making this work with a fresh set of users/groups? The data for which has been setup properly of course (emails enabled & defined).



Also, can you paste the final BR & notification that we are triggering, its an awfully long post to go through again.



Thanks in advance!


Hi Saksi,



We have recently cloned back our production environment to TEST and DEV so we know the users are setup correctly as they are getting other notifications.



Business Rule


find_real_file.png


find_real_file.png



Notification



find_real_file.png


find_real_file.png


find_real_file.png



find_real_file.png



Let me know if you need anything else



Thanks


Hi Sakshi,



Do you need anything else from me other than the above, would like to try and get this one ticked off



Thanks



Sam