Lifecylce events: Show fields from parent HR Case in child HR Case

Charlotte
Tera Contributor

I have a lifecycle event (triggered by record producer "Change job") with 2 activities (Advice manager & Advice director) in it.

The manager should see the filled in fields by the employee, and the director should see the filled in fields by the employee and the manager.

 

Record producer: "Change job"

Variables:

1. current job (lookup select box to table "hr profile", read only)

2. new job (reference to table "jobs")

 

Activity 1: Advice manager

Employee activity = HR Task based on an HR Service with a record producer where I need to populate variables with data from the HR Parent case.

Variables:

1. current job auto populated with data from "parent HR Case Change job" (lookup select box to table "hr profile", read only)

2. new job auto populated with data from "parent HR Case Change job" (reference to table "jobs", read only)

3. new job proposal manager new field where manager can choose other job (reference to table "jobs")

 

Activity 2: Advice director

Employee activity = HR Task based on an HR Service with a record producer where I need to populate variables with data from the HR Parent case & Activity 2.

1. current job auto populated with data from "parent HR Case Change job" (lookup select box to table "hr profile", read only)

2. new job auto populated with data from "parent HR Case Change job" (reference to table "jobs", read only)

3. new job proposal manager auto populated with data from "HR Case Advice manager" (reference to table "jobs", read only)

4. new job proposal director new field where director can choose other job (reference to table "jobs")

 

I've created a before insert Business rule with this code for the 1st activity:

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

var gr = new GlideRecord('sn_hr_le_case'); //parent table
gr.addQuery('sys_id', current.parent);
gr.query();
if(gr.next()) {

current.CF_CURRJOB = gr.CF_CURRJOB;
current.CF_NEWJOB = gr.CF_NEWJOB;

gr.update();
}

})(current, previous);

 

This is not working 😞

 

For the 2nd activity I have no business rule yet.

 

Thanks in advance for the help!

1 ACCEPTED SOLUTION

If the fields are not on the sn_hr_le_case table, you will not able to read that table and pull the values to add to another child task.  

Are you generating the two child tasks via a workflow, activities in activity set (on lifecycle event) or through service activities on normal HR Service?  If using a workflow, you can store the variable values to a scratchpad to add to the new task.  Otherwise, you would need to add fields to the LE case table, map those variables to the fields on the table to pull in those values for the next tasks.  Your business rule should be written on the sn_hr_core_task table, because you are wanting it to run on the task creation when the task's parent is not empty and whatever other conditions to limit it's running (e.g., short description of tasks or templates).  Then you would read the sn_hr_le_case table where the sys_id matches the "parent" on the sn_hr_core_task record (i.e., current.parent).

View solution in original post

4 REPLIES 4

Susan Britt
Mega Sage
Mega Sage

Do you have the two variables from the parent case mapping back to custom fields on the sn_hr_le_case table to pull with the business rule?  What table is your business rule written on?

 

Hi Sbritt

no, I'm not mapping the variables, because I don't have these kind of fields on the table sn_hr_le_case, which is also the table my BR is made on.

Thanks in advace!

If the fields are not on the sn_hr_le_case table, you will not able to read that table and pull the values to add to another child task.  

Are you generating the two child tasks via a workflow, activities in activity set (on lifecycle event) or through service activities on normal HR Service?  If using a workflow, you can store the variable values to a scratchpad to add to the new task.  Otherwise, you would need to add fields to the LE case table, map those variables to the fields on the table to pull in those values for the next tasks.  Your business rule should be written on the sn_hr_core_task table, because you are wanting it to run on the task creation when the task's parent is not empty and whatever other conditions to limit it's running (e.g., short description of tasks or templates).  Then you would read the sn_hr_le_case table where the sys_id matches the "parent" on the sn_hr_core_task record (i.e., current.parent).

Hi Sbritt

as you proposed, I added extra fields to the LE case table and mapped those variables to the fields on the table to pull in those values for the next tasks. I did the field mapping in the activity, so without business rule. Works like a charm!

Thanks for the help!