Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to autopopulate HR Parent Case field when an Lifecycle Activity/HR Task is triggered

Phong Lo
Tera Guru

Hi all,

 

I have a requirement to auto-populate a field (Field: X Name, u_x_name) by concatenating a few values in a HR Onboarding Case table (extended from HR Case table) when the Remote User (remote_user) field = Yes and a specific Lifecycle Activity/HR Task (Activity Name: X HR Task) is triggered. 

 

I created a before BR on insert and update targeting the HR Onboarding Case Table with the following condition and script:

Condition: Remote User - is - Yes OR Remote User - changes to - Yes

Script:

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

    if (current.remote_user == 'yes') {
        current.u_x_name = current.u_contract.u_agency.getDisplayValue() + ' - Remote User - ' + current.subject_person.first_name + ' ' + current.subject_person.last_name;
    }

})(current, previous);

 

The BR works when the Remote User field = Yes, but I specifically want the 'X Name' field to auto-populate when the Lifecycle Event of 'X HR Task' is triggered. Can I accomplish this using a BR? I'm not sure how to add the Lifecycle Activity to the BR if that's the case. Or can I implement this elsewhere? Anything helps! Thank you!

 

Providing screenshots below of the Activity, HR Task Template, and Activity Set (redacted for privacy): 

PhongLo_0-1732203976208.png

PhongLo_1-1732204138410.png

PhongLo_2-1732204271559.png

Other Activity Sets Tab: Activity set dependencies = Document Signature Request (this Task will fire after documents are signed)

Condition Tab: Remote User - is - Yes

 

 

 

0 REPLIES 0