- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2015 11:26 AM
I am running a Catalog Client Script:
function onLoad() {
//standard template
var varPos = g_form.DisplayBox('new_hire_position').value;
if(varPos == 'Telephone Cust Serv Rep') {
g_form.setValue('cics_fees', "true");
......And so on
This client script is used for template access - that if the user has a specified position this should trigger. I have the new_hire_position field on the catalog item that is being passed from the Order Guide. If I call the value of the position field as shown above the template works great but when I get to the requested item all of my UI policies break. If I change it to something else the ui policies work but the template doesn't. I've read this KB article: https://hi.service-now.com/kb_view_customer.do?sysparm_article=KB0532703 and I can't find an ACL that is running on that field. I found this post: How do I get the display value of a field? and tried the variation recommended var varDisp = g_form.getDisplayBox(g_form.resolveNameMap("variable_name")).value; with no success. Has anyone ran across this issue and found a solution or have recommendations?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 10:27 AM
Hi LIndsey,
I can confirm that the getDisplayBox is not working on sc_req_item table(variable editor). You have to switch to getReference() in that case.
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 09:19 AM
Hi Lindsey,
Sorry, I overlooked it. Yes it should be getDisplayBox.
Thanks
Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 09:56 AM
This is what I have running now:
function onLoad() {
//standard template
var varPos=g_form.getDisplayBox('new_hire_position')?g_form.getDisplayBox('new_hire_position').value:'';
alert(varPos);
if(pos ='Telephone Cust Serv Rep') {
g_form.setValue('cics_fees', "true");
on the catalog item its working and the ui policies are working, however, when I get to the requested item, the alert pops up but is blank. I did notice that if I try and change the value but using the back arrow to the Order Guide that the Catalog Item doesn't update with the new information. Previously this would change if I changed the position on the Order Guide.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 10:27 AM
Hi LIndsey,
I can confirm that the getDisplayBox is not working on sc_req_item table(variable editor). You have to switch to getReference() in that case.
Please let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 10:45 AM
For such scenarios I try to use this type of code on catalog client script
if(g_form.getTableName() == 'sc_req_item' || g_form.getTableName() == 'sc_task')
{
//this for RITM and task
}
else
{
//this will run on catalog item
var varPos1=g_form.getDisplayBox('assignment_group').value;
alert(varPos1);
}
For getting the variable's display value, there is no stable method as per my knowledge. You can play with DOM and get the display value but that would be error prone during future upgrades. I would suggest you either do a glideAjax or use display business rule for getting the display value of reference fields.