How to set size of GlideModalForm?

John Rissone
ServiceNow Employee
ServiceNow Employee

I'm using GlideModalFormV3 and there doesn't seem to be a way to size the thing as there are no documented APIs to do this.

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=c_GlideModalFormV3API

We can hack it via the callback and add the class "modal-lg" to the ".modal-dialog" node, but then the modal snaps after it loads to the smaller size and looks terrible.

With the new SN mandate to not use Jelly UI Pages, I'm out of ideas. 

6 REPLIES 6

The Machine
Kilo Sage
There is a .setWidth function. Don’t see anything about set height but with bootstrap that should be dynamic.

Mike Patel
Tera Sage

try doing below

var d = new GlideModalForm('dialog title', 'table_name_or_form_name', [callback on completion of submit])
         d.setPreference('name', 'value');
d.setWidth("300"); 
         d.render();

Mike Patel
Tera Sage

you can also add height like below

d.setWidth("95%");
d.setHeight("95%");

Joe72
Tera Contributor

For the GlideModalForm object, there is no setHeight function, and the setWidth function is hardcoded to return 'modal-95', no matter what you pass in.

GlideModalForm.setWidth:

ƒ (width) {
this.setSize(width);
}

GlideModalForm.setSize:

ƒ (width) {
this.size = 'modal-95';
}