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.

HR Case Record Producer Script not working

Julia Baus
Kilo Guru

I am trying to write a script in the record producer to achieve the following:

new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
a) Set the short description as Rückkehrer - <name of the subject person>
Note: subject person is set as the value from a reference variable via field mapping
b) Set the opened for as the manager of the subject person
c) Set the value of a custom reference field as the logged in user
 
I was trying the following but no success. Can someone help:
current.short_description = "Rückkehrer - " + producer.subject_person.name;
current.opened_for = producer.subject_person.manager;
current.u_current_obv = gs.getUser();
1 ACCEPTED SOLUTION

Julia Baus
Kilo Guru

Found the following solution which works for me:

var gr = new GlideRecord('sys_user');
gr.get(producer.sds_onb_subject_person);
if(gr.manager){
    current.opened_for = gr.manager;
}
current.short_description = "Rückkehrer - " + gr.name;
current.u_current_obv = gs.getUserID();

View solution in original post

2 REPLIES 2

Julia Baus
Kilo Guru

Part c) I was able to solve myself correcting it to:

current.u_current_obv = gs.getUserID();

Julia Baus
Kilo Guru

Found the following solution which works for me:

var gr = new GlideRecord('sys_user');
gr.get(producer.sds_onb_subject_person);
if(gr.manager){
    current.opened_for = gr.manager;
}
current.short_description = "Rückkehrer - " + gr.name;
current.u_current_obv = gs.getUserID();