- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-17-2023 08:58 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 04:47 AM
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();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 06:59 AM
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.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 04:47 AM
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();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 05:04 AM - edited ā10-18-2023 05:06 AM
Thanks for code, its working fine, but as i mentioned above, in the body i want
Hi <HR service name>
Please note that the tasks you have requested on ${date_of_tasks_submitted} for ${employee_name} (subjected person)have now been marked as complete.
Like that but i am unable drag these fields on the body using parent case, but here parent means , it shows the main task fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 05:17 AM
Glad to know.
which fields you want to show? notification is on HR task so you can show that fields
you can also dot walk to parent and pick employee name
what's the challenge?
Date of tasks submitted will be different for each task under that HR case and it will be different value. Which one you want to print in email body
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 05:36 AM - edited ā10-18-2023 06:06 AM
I have tried to dot walk from parent field, but it shows the list of parent task field not the parent case.
Basically i want HR service name and Employee name fields from the parent case in the notification body ?
And also want all the date of submitted for tasks if possible or the last task date submitted ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-18-2023 06:33 AM
you should able to print HR Service by dot walking to parent-> HR Service -> name
please share your screenshot of email body
Since you said dates of all tasks then you need to use email script and then use GlideRecord to get all HR Tasks and print it
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader