Need to trigger a notification when all the tasks associated with case closed complete?

Ramu6
Tera Contributor

Hi All,

I have a requirement that , basically when HR case is created , they manually create HR tasks, i want to trigger a notification that it checks all the tasks associated with case as closed complete then the notification will trigger to health group? and that includes body as 

Hi <HR service name>

Please note that the tasks you have requested on <date of tasks submitted> for <Employee Name> have now been marked as complete.

 

Please help to resolve this

 

Thanks

Ramu

2 ACCEPTED SOLUTIONS

@Ramu6 

then do this

1) have notification on HR Task, with your subject, body etc. I hope you know how to do this

Condition as State Changes to Close

2) Use advanced condition in notification and check if this task is the last one; if yes then set answer=true

var gr = new GlideRecord("sn_hr_core_task");
gr.addActiveQuery();
gr.addQuery("parent", current.parent);
gr.setLimit(1);
gr.query();
answer = !gr.hasNext();

AnkurBawiskar_0-1697629607150.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

@Ramu6 

something like this. please enhance

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here

	var gr = new GlideRecord("sn_hr_core_task");
	gr.addQuery("parent", current.parent);
	gr.query();
	while (gr.next()) {
		template.print("Please note that the task you have requested on " + new GlideDateTime(gr.sys_created_on).getDate() + "for " + gr.parent.subject_person.name + " have now been marked as complete.");
	}


})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

12 REPLIES 12

@Ankur Bawiskar 

can you please provide me the email script for the Dates , if possible?

 

Thanks

Ramu

@Ramu6 

something like this. please enhance

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here

	var gr = new GlideRecord("sn_hr_core_task");
	gr.addQuery("parent", current.parent);
	gr.query();
	while (gr.next()) {
		template.print("Please note that the task you have requested on " + new GlideDateTime(gr.sys_created_on).getDate() + "for " + gr.parent.subject_person.name + " have now been marked as complete.");
	}


})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

Thank you so much , its working fine