get.DisplayBox().value Failing UI Policies

ljschwaberow
Giga Expert

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?

1 ACCEPTED SOLUTION

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.


View solution in original post

8 REPLIES 8

srinivasthelu
Tera Guru

I think somehow you are ending up with fetching value from null object.




Try replacing




var varPos = g_form.DisplayBox('new_hire_position').value; with




var varPos=g_form.DisplayBox('new_hire_position') ? g_form.DisplayBox('new_hire_position').value :   '';


Hi Srinivas! Thanks for your replay. I tried replacing this line with what you suggested and the client script and the ui policies break on the catalog item. With the var varPos = g_form.DisplayBox('new_hire_position').value;   line I put varPos in an alert and it does alert the correct value on the Catalog Item but then doesn't alert anything when it gets to the requested item.


Hi Lindsey,



Could you please paste the browser console errors here?



Thanks


Srinivas


In looking at the browser console errors, is that line suppose to have "get" in front of each DisplayBox()? It's saying that DisplayBox() is not a function. I think this is an error from when I copied my code over. If I put getDisplayBox instead it picks up the value of new_hire_position but the ui policies on the catalog item are still breaking. Here's the browser console errors after I added 'get':



"[CustomizableUI]" "Custom widget with id loop-button does not return a valid node" CustomizableUI.jsm:167


Use of attributes' nodeValue attribute is deprecated. Use value instead. js_includes_doctype.jsx:22945:0


NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsITaskbarTabPreview.invalidate] WindowsPreviewPerTab.jsm:406:0


Use of attributes' nodeValue attribute is deprecated. Use value instead. js_includes_doctype.jsx:22945:0


NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsITaskbarTabPreview.invalidate] WindowsPreviewPerTab.jsm:406:0


Use of attributes' nodeValue attribute is deprecated. Use value instead. js_includes_doctype.jsx:22945:0


NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsITaskbarTabPreview.invalidate] WindowsPreviewPerTab.jsm:406:0


Use of attributes' nodeValue attribute is deprecated. Use value instead. js_includes_doctype.jsx:22945:0


NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsITaskbarTabPreview.invalidate]