HR Case Record Producer Script not working

Julia Baus
Tera Expert

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
Tera Expert

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
Tera Expert

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

current.u_current_obv = gs.getUserID();

Julia Baus
Tera Expert

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();