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.

Reference field being set by business rule is getting sys_id but it's not displaying correctly

e_wilber
Tera Guru

I have no idea what's going on.

 

This field is being set in a business rule (you can see there's a sys_id attached to it but it's empty):

e_wilber_0-1691158225474.png

The field data looks like: 

e_wilber_1-1691158263608.png

 

//patient is the sys_id as a string

var wot = new GlideRecord('wm_task');
wot.initialize();
wot.parent = ev.u_work_order;

wot.u_patient = patient;

wot.insert();

 

Why isn't this field being set correctly?

5 REPLIES 5

Riya Verma
Kilo Sage

Hi @e_wilber ,

 

Hope you are doing well.

 

Try using below script for setting the reference field value:

 

var wot = new GlideRecord('wm_task');
wot.initialize();
wot.parent = ev.u_work_order;
wot.setValue('u_patient', ' <sys id o patient which your want to set>' ) 
wot.insert();

 

 

And also make sure to check the referencing table has exactly once column with display ="true".

 

 

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma