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 on Record Producer show Default Value in String field on Task Form?

richelle_pivec
Mega Guru

I am developing a record producer and form for one of our teams. On the record producer, I'd like to use a reference field for the Contact Name, and I have this code in the Default Value field: javascript:getReqfor(gs.getUserID())

It works great to pull the name of the Requested By from the Catalog into the Record Producer. However, the corresponding field on the form is a String field because when it is created directly by someone on our HR team, the person in the Contact Name field might not be someone in our system (a spouse calling about a benefit or something like that). So, I'd like it to use the reference field on the form when an Employee or Contractor uses the record producer on the CMS portal, but I'd like that field to be a string field on the Form itself.  

The Contact Name that is displaying in the reference field on the record producer is populating the corresponding string field on the form with the Sys_ID instead of the Display Value. Any idea on how I can get it to resolve that Sys_ID to the referenced name?

thanks,

Richelle

1 ACCEPTED SOLUTION

paramveer
Mega Guru

instead of write that code in default value of string field, write the same code in script field of "What it will contain" tab of Record producer. Then it should work.



find_real_file.png


Like code written above in script field.



Thanks,


Param


View solution in original post

7 REPLIES 7

paramveer
Mega Guru

instead of write that code in default value of string field, write the same code in script field of "What it will contain" tab of Record producer. Then it should work.



find_real_file.png


Like code written above in script field.



Thanks,


Param


I have removed the code from the field on the form and added it to the script field on the record producer...I tried it both above and below the redirect line. Still didn't work.



hrr.png



Any other thoughts on what I could try?


thanks,



Richelle


Your answer was correct. I needed to remove ".string" from the code...this code worked in the script on the record producer:



current.u_contact_name = producer.u_contact_name.getDisplayValue();



I misread your example above.


Thank you so much for your help!



Richelle