Notification needs to be triggered after Child HR Task is complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 09:09 PM
I want to trigger the notification after the HR Task is marked completed. This task is the child task on Lifecycle Event case. I can trigger the notification on HR Task table but I have to send the notification to Parent case - Subject Person. How do I reference the Parent case from the HR task table. I didn't find a way dot walk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 09:31 PM
Hi @Simran321 ,
Can u try something like below
(function executeRule(current, previous /*, g*/) {
// Check if HR Task is marked as completed
if (current.state == 3 /* Completed */) {
// Get the parent Lifecycle Event case
var parentCase = new GlideRecord('my_case_table'); // Replace 'my_case_table' with the actual table name of your Lifecycle Event case
if (parentCase.get(current.parent.sys_id)) {
// Now you have access to the parent case fields, such as Subject Person
var subjectPerson = parentCase.subject_person;
// Trigger your notification logic here, using subjectPerson variable
gs.eventQueue();//please trigger the notification via this command
}
}
})(current, previous);
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2023 01:03 PM
Hi Simran,
Since the "Parent" on the HR Task is from the core task table not the HR Case table, so you cannot dot-walk to HR Case specific fields (e.g., Subject Person). I like to recommend adding a custom field (e.g., Parent HR case) on the HR Task table to point to the sn_hr_core_case table, so if ever needed, you can dot-walk to necessary HR Case specific fields. Then create a BR to populate that value on creation of any HR Task. This will allow you to dot-walk to the parent case's subject person within the notification.
Business Rule details:
- Table: sn_hr_core_task
- Advanced: true
- When: Before Insert
- Order: 50
- Conditions: Parent is not empty
- Advanced:
(function executeRule(current, previous /*null when async*/ ) {
/* The Parent on the HR Task references the core task table, which does not contain the HR Case specific fields to reference later (e.g., Subject person). This script is populating the custom Parent HR Case field on the HR Task with the "parent" value, but references the HR Core table instead, so we can dot-walk to HR Case specific fields on the child HR Task. */
current.u_parent_hr_case = current.parent;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2023 02:02 PM
Hi @Simran321
If the HR Task you refer to is part of an activity set, try using an Activity Container. You can have the task as the first activity in the container, and then have the notification as the second activity. You can then reference the parent case fields in the normal way from the activity field mapping.
Hope this helps.
David.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2023 02:11 PM
Hi @Simran321
In addition to my other suggestion, you can actually reference the parent case subject person in the notification config (it just takes a bit of searching). If you expand out the Parent case fields in the "Who will receive" picker you can find fields related to extended tables (see below).
This is using the HR Task table as the trigger for the notification.
Hope this gives you some options.
Regards,
David.