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.

Change order of fields on form

maryc
Tera Contributor

Hi,

I have a choice fields with 3 values and in total there are 6 fields on a form.

Based on the selection of a choice field, I want the fields on the form to rearrange itself( some fields have to show and others should not be visible) .

I am using setDisplay() method on g_form, but its leaving out some white spaces in between the fields.

Is there a way to rearrange the fields so that there is no white space between the fields?

Thanks

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hey Mary,



This behavior is generally seen when you use setVisible to display/hide the field. if thats the case then you have to replace setVisible with setDisplay in all your scripts.


Also as a best practice try to use UI policy wherever possible.


http://wiki.servicenow.com/index.php?title=Creating_a_UI_Policy



I hope this helps


View solution in original post

6 REPLIES 6

russell_miller
Kilo Guru

Hi May,



Try the setVisible() method instead of setDisplay().



Hope that helps.


march
Kilo Guru

I would also advise you to try using UI Policy when possible rather than client script.


maryc
Tera Contributor

Hello,



I am using UI policy and I have this script, but I am seeing that the fields dont get pushed up or down   and empty field space is still visible



g_form.setVisible('u_tableField',false);


Hi Mary,



It should be setDisplay . Wiki says it here GlideForm (g form) - ServiceNow Wiki.



Could you please share the screenshot where the space is not reclaimed with setDisplay.



Mark this response as correct/helpful if it does so


Thanks


Srini