Re-sizing a reference variable width in the item and/or task

A523
Kilo Contributor

Hello,

        I found an article on how to re-size a reference variable in the catalog item. Here is the link https://community.servicenow.com/thread/177647

Here is the code used

var myVar = $('sys_display.' + g_form.getControl('<variable name>').id); //Get the correct reference element

myVar.style.width = '350px'; //Set the width


    It works well in the catalog item but it does not work in the item or task. I tried to change the name and tried a few other options that I found

  g_form.getControl('variables.name').style.width = '350px';

  for (var i = 0; i < g_sc_form.nameMap.length; i++) {

      if (g_sc_form.nameMap[i].prettyName == '<variable name>') {

          g_form.getControl(g_sc_form.nameMap[i].realName).style.width = '350px';

      }

  }

So far, no luck.

Any of you have some other ideas to get it to work in the item and task as well.

Thanks...Jim

17 REPLIES 17

Hi Johnny,



For variables on Requested Items you can use:



`g_sc_form.getDisplayBox(variable_name).style.width = '350px';`



For task variables you can do this by defining a field style like:



'width: 350px !important;'


What version are you on? I did the test in my fuji instance and it works from catalog item all the way down to task.   see screenshot. Can you share your code?



Screen Shot 2016-04-08 at 2.13.30 PM.png


I'm on Fuji Patch 10.



I create a new catalog item to rule out any other scripts I may have running, but still not working. I also disabled all other UI policies and client scripts from the Request Item as well to rule out anything interfering with this catalog client script.



Here is my catalog client script:


Client_script_test.png



It works on the catalog item:


Catalog Item.png



Doesn't work on the request item.


RITM.png


if you bring up developer tools in your browser do you see any client errors?



If you need help, I can jump on a quick websession to fix the issue.


Thanks Patrick.   I am getting errors seen here:



error.pngline309.png