Updating HR profile value

sanvi
Tera Expert

Hi All,

 

I have a requirement for adding 'User HR profile' value in Associated Allgetaion table.

So i have created a custom field on 'Associated Allegations' table called USER HR PROFILE which is a reference field referring to user HR profile table. I am trying to populate the value on this field based on the 'Subjects of Allegation' field value. So to achieve this i have configured the below business rule.

 

When : Before -Update

var prof = current.involved_party;
    gs.addInfoMessage("value of subject of allegation"+ prof);
    var hrProf = new GlideRecord('sn_hr_core_profile');
    hrProf.addEncodedQuery('user='+prof);
    hrProf.query();
 
    if(hrProf){
        gs.addInfoMessage("value of subject of allegation inside loop"+ hrProf.user );
 
        current.setValue('u_user_hr_profile', hrProf.user.u_name);
        current.update();
}
   
I am getting undefined value for this Info message
sanvi_0-1748411262585.png

 

Can anyone suggest.

 
7 REPLIES 7

HI @Ankur Bawiskar ,

 

Yes 'Involved_party' is referring to 'sys_user' table.

And yes the HR profile is present for the user selected but still not entering the if condition.

 

I tried removing if.next() and added only if... in this case script enters if condition but getting 'undefined' value.

 

 

@sanvi 

did you try to run background script with that hard-coded sysId of user and see if record is found?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@sanvi 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader