How Can I populate HR case description in HR Task

Anmol12
Tera Contributor

I am having issue populating the description from HR Case to HR Task, I have a rich_description field on both HR case and HR Task and I am setting up some fields on HR Task via HR Template  but it's not able to set the description from HR case in HR Task. Since rich_description field created on case level so {$parent.rich_description} not working as parent will be task table.
I have also tried in workflow script but that is also not working. Can someone help me who came across such issue?

Thanks,
Anmol

2 ACCEPTED SOLUTIONS

Hi @Anmol12,

To populate the 'rich_description' from an HR Case to an HR Task in ServiceNow, you can use a combination of Business Rules, Script Includes, or Workflow Scripts. Since the '{$parent.rich_description}' is not working directly, you may need to manually script the population of the field.

Alternative Approach Using Workflow Script

If you are using a workflow, you can also achieve this with a workflow script:

1. Add a Script Activity to Your Workflow
- Open your HR Case workflow.
- Add a new `Script` activity to the workflow.

2. Configure the Script Activity

 

// Get the current HR Case and its HR Task
var hrTask = current; // Assuming this script runs in the context of an HR Task
var hrCase = new GlideRecord('sn_hr_core_case');

if (hrCase.get(hrTask.parent)) {
// Copy the rich_description from the HR Case to the HR Task
hrTask.rich_description = hrCase.rich_description;
hrTask.update(); // Save the HR Task record
}

 

This script assumes that it is being executed in the context of an HR Task within a workflow. It retrieves the parent HR Case and copies the 'rich_description' to the HR Task.

 

Thank you, please make helpful if you accept the solution.

View solution in original post

@Anmol12  What do you mean by rich_description field is not present on task table ? 

I am just doing dot walk to get parent record field value, in this case parent is holding HR Case record and rich_description exist there so it can fetch the value. 

 

Have you tried to reproduce this on your personal instance ?

If you are doing it on your org instance then try to check any existing BR is not contradicting here ? Also try to lower your BR order to see if it executes or not, add some logs in BR . 

 

Let me know if you have any further question for me.

 

Thanks,

Harsh

View solution in original post

13 REPLIES 13

James Chun
Kilo Patron

Hi @Anmol12,

 

Please do not create a custom BR, you were on the right track by using the HR Template.

Instead of {$parent.rich_description}, it should be ${parent.description}.

 

HR Task Template Configuration:

JamesChun_0-1717795599880.png

Outcome:

JamesChun_1-1717795663783.png

 

Cheers

When I give ${parent.description} in template it doesn't align the text properly. HR case description contains information of record producer variables so when I give ${parent.description} in template for rich description field in HR Task it populate but doesn't align properly.

SanjivMeher
Kilo Patron
Kilo Patron

If you just want to show the description of HR Case in Task, Why not just add the HR Case description to the form of HR Task.

But if you really need to copy the description, Make sure the Business Rule you create is an onBefore Rule which should run on Insert. And use the script Harsh Vardhan has suggested.


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,
I want to copy the description only for a particular HR task not globally and the BR script which Harsh provided not working as rich_description is created on HR case table not on parent (task table). 

Thanks,
Anmol