Re-sizing a reference variable width in the item and/or task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2015 01:52 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016 01:14 PM
is that a "1" in style vs "l"(L) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016 01:27 PM
Nope. It's a "L".
Here it is copied and pasted. I would expect to get an error on the catalog item as well if it was a syntax error.
g_form.getDisplayBox('resource_name').style.width = '500px';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016 02:05 PM
What browser are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 06:36 AM
I am using IE10 as the standard, but have also tried on Chrome and Firefox with the same results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016 02:33 PM
Johnny,
On the catalog item you can have name conflicts with variables vs task fields, so you need to be careful about script and naming. One approach that should work in both places would be the following:
// Dynamically update a Catalog Variable width
function onLoad () {
if (typeof g_sc_form !== 'undefined') {
g_sc_form.getDisplayBox('field_name').style.width = '350px'; // Works better on Req Items / Cat Tasks
} else {
g_form.getDisplayBox('field_name').style.width = '350px'; // Works better on Cat Items
}
}