Get Parent HR Case Hr Service on to the Hr Task form view which is the child of HR Case

Narasimha10
Tera Contributor

Hi All,

 

I have a requirement where i need to cascade the hr service from HR Case(parent) to HR Task(child).

I am trying from Form Layout where in the available section i have searched for Parent and expanded the field but still could not find the HR Service of the Parent.

Can anyone please help me on this

Narasimha10_0-1720704770201.png

 

4 REPLIES 4

Rob Sestito
Mega Sage

Hi @Narasimha10 - 

I do not think this is possible without some scripting involved. You would need to create a new custom field on the HR Task form. Something such as: Parent HR Service (u_parent_hr_service). Then also create a Business Rule or Script Include to handle the information needed.

 

You can already see the HR Service from the Parent Case, by clicking on the Information Icon next to the Parent field. From there, you can see some information in a popup box, and can also see the HR Service being used.

RobSestito_0-1720708423069.png

 

 

IF... And IF you really want to create this custom work. Then you can do the following (I did this in my PDI and it works):

 

  • Create your custom field onto your HR Task form (give it a name you feel appropriate and mark is as Read Only as this will be a string field and we don't want anyone changing it on purpose or accidentally)
  • Create new Business Rule with the following details:

RobSestito_1-1720709286313.png

In the Advanced tab: (be sure to change the custom field name in this script with what you have - if you selected to use a different name)

(function executeRule(current, previous /*null when async*/ ) {
    // Get the parent HR Case record
    var parentCase = new GlideRecord('sn_hr_core_case');
    if (parentCase.get(current.parent)) {
        // Set the HR Service field on the HR Task form to match the display value of the parent HR Case's HR Service field
        current.u_parent_hr_service = parentCase.hr_service.getDisplayValue();
    }
})(current, previous);

 

Now when you create a new HR Task (or one is generated automatically):

Parent HR Case:

RobSestito_3-1720709523998.png

 

Child HR Task:

RobSestito_2-1720709491484.png

 

Let me know if this helps you out - whether you stick with what is OOTB and just have HR Agents click on the Informational Icon from the Parent Field - Or go with some custom work to populate the HR Service into a custom field.

 

Cheers!

-Rob

*Please remember to mark replies as Helpful and/ or Correct when appropriate*

 

Narasimha10
Tera Contributor

Hi Rob,

Thanks for giving detailed explanation with code.

I am looking for OOTB functionality (if it is there) and yes even I have tried with custom script by creating new field on HR Task.

@Narasimha10 There is no OOTB functionality to copy HR Service from Case to child Task. Apart from what Rob suggested, an alternate approach could be to add a custom reference field on HR Task, which refers to HR Case table. Since this is going to be a reference field referring to HR Case table, you can add a dot walked HR Service field on the HR Task form using the form layout.

 

You can populate this custom HR Case field with the value of parent field using an onBefore insert business rule on HR Task.

 

Hope this helps.

@Narasimha10 - 

As both @Sandeep Rajput and I have pointed out (including my first couple of sentences provided in my initial reply); there is no OOTB way to do so. You would need to do some custom work. Either what I have shown above or what Sandeep has pointed out. With no OOTB way, those would probably be your best options to get what you are looking for on your requirement.

 

Hope our suggestions have helped you.

Cheers,

-Rob