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.

Customizing the width of fields on a producer or form

Not applicable

I am currently using a record producer to insert new records into a table; however, I'm having trouble customizing the look and feel of it. I have several single line text variables on the producer that I would like to customize. I have two problems specifically.

1. I would like change the displayed width of the text field on the record producer. I have used the CSS capabilites to change the width of a field on a form, but I can't seem to find anything similar for a record producer that would allow me to change this. How can I do this?

2. On the form where I view records that have been inserted using the producer, I have several labels that are too long for the default width and actually cause the label (not the value) to wrap and use multiple lines. Is it possible to change the default width of the label portion so that it doesn't wrap? If so how would I do this?

I haven't been able to find any information on the Wiki, so any help would be appreciated.

Thanks!

6 REPLIES 6

john_roberts
Mega Guru

For #1.
Until we add style controls for variables (at least I don't think we have them yet), you can use the following client script to set the style.


function onLoad() {
//you can get the field element id by using a DOM inspector
//or setup a temporary onChange event on the field of interest
//and use alert(control.id)

var field = gel("sys_display.IO:3f20109c0a0a0b9900a3002701f54fbb");
field.style.width="400px";
}


Not sure on #2.


Thanks for the reply. I had thought of using the ID of the control, I just wasn't sure if it would always be the same, or if it was dynamically generated somehow.

Anyone else have an idea for #2?

Thanks in advance.


Not applicable

If your variable has a name, you can get ahold of its control with:

g_form.getControl() e.g.

g_form.getControl('dog');


DanielStyer
Kilo Contributor

function onLoad() {
//code used to determine the control's id
// record the control's id number provided
/*
var loc_from = g_form.getControl('mp_from_location');
alert('mp_from_location: ' + loc_from.id)
*/

// insert control's id number after the sys_display.IO.
var field = gel("sys_display.IO:3f20109c0a0a0b9900a3002701f54fbb");
field.style.width="400px";
}