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

We know the UI Policy is sending a sys_id from the sys_user table.  Can you confirm that the requested_by variable is referencing the sys_user table?  Is the sys_id shown one that belongs to a user record that you could then manually select?  It shouldn't affect the outcome, but is there a reason you are doing this in a UI Policy, instead of the more commonly used Client Script?

Its referencing the vendor contact table and I am able to manually select the vendor contact, its just the autopopulation that is pulling in the sys_id.

Per business requirements, they are opting to use ui policies over client scripts due to issues in the past with upgrades and client scripts not working.

Maybe I'm not understanding something back at the beginning.  This is a Record Producer for which table?  As a Vendor Contact, I am submitting this to do what?

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