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.

Catalog UI Policy Script returning SysID and not the Display Value

charri04
Tera Expert

Hello developers,


Quick question,

I have a record producer that's built off of the vendor contact table to allow vendors to submit requests. I have a UI policy script to auto-populate the vendor contact's name into the requested by field. This part is partially working.

So its pulling the sys_id of the vendor contact instead of their actual name in requested by field.

Could someone check my this script to see if its correct?

function onCondition() {

g_form.setValue('requested_by',g_user.userID);
g_form.setReadOnly('requested_by',true);
g_form.setMandatory('requested_by',false);
}

Any guidance will be greatly appreciated!

 

Best regards,

 

 

Corey

1 ACCEPTED SOLUTION

Hi @Brad Bowman  
Finally got the issue resolved and it was just a role issue. We needed to add the 'vendor_contact' role to the user's profile and that fixed the issue.

 

Thanks for your help on this issue.

Best regards,

 

Corey

View solution in original post

8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

Typically you want the sys_id to populate into a reference field on the sys_user table.  This prevents typos, same name confusion, etc. The reference field will display the Name of the user, not the sys_id.  Is requested_by not a reference variable?  Is it mapped to a field?

Hi @Brad Bowman  

Thanks for responding!

Yes, the requested_by field is a reference variable. It's not mapped to a field, we just want the vendor contact to know they are the correct person that is submitting the request (per business requirements).

 

Best regards,

 

 

Corey

I guess I am not following then - are you seeing a sys_id when the UI Policy script populates the variable?  Do you see the same when you manually select a record in requested_for? 

Hi @Brad Bowman  

Apologies on the late response. I got sidetracked working on a different issue. But yes, when the ui policy populates the variable, its showing the sys_id in that field. However, its a reference field so when I manually select a record, it shows the actual name of the requestor.

 

Best regards,

 

Corey