- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 06:49 AM
I've been tasked to change the OOB "Create Outage" ui action on change requests to have it open in a new window or popup.
I've seen the ServiceNow Guru page and some others, but nothing is working.
According to SNOW Docs, the GlideWindow and GlideDialogWindow are deprecated.
So i thought to use the new GlideModal. When I added this in my UI Action, I'm getting GlideModal is not defined.
I also got that when using the GlideWindow apis.
I found a post showing the code for GlideModal and added it to my environment.
var GlideModal = Class.create(GlideWindow, {
initialize: function(title, readOnly, width, height) {
GlideWindow.prototype.initialize.call(this, 'dialog_form', readOnly, width, height);
this.setTitle(title);
this.setClassName('glide_modal');
this.setBody(TEMPLATE);
this.setFooter(FOOTER);
}
});
My UI action is
function openNewWin(){
var tyP = g_form.getValue('u_maintenance_type');
if(tyP=='major'){
tyP = 'outage';
} else {
tyP = 'planned';
}
var newOut = new GlideModal("Outage Task");
newOut.setTitle("Outage");
newOut.setPreference("sys_id",-1);
newOut.setPreference("table","cmdb_ci_outage");
newOut.setPreference("sysparm_query","short_description"+g_form.getValue("short_description")+"^task_number="+g_form.getUniqueValue()+"^cmdb_ci="+g_form.getValue("cmdb_ci")+'^type='+tyP+"^begin="+g_form.getValue("start_date")+"^end="+g_form.getValue("end_date"));
newOut.render();
}
The form is opening and populating the fields as desired.
When I click the SAVE button, i'm getting the following error because it's setting the table as Change Task and not Outage.
What did i do wrong.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 08:22 PM
@EricG Have you tried this on personal instance ?
Also can you try to access this url, it contains the js libraries , this is ootb .
https://<YourInstanceID>.service-now.com/scripts/classes/GlideModalFormSetWidth.js
Can you try again with this script :
function openNewWin() {
var dialog = new GlideModalForm("Outage Task", "cmdb_ci_outage");
dialog.setSysID("-1");
var q = 'short_description=' + g_form.getValue("short_description") + '^task_number=' + g_form.getUniqueValue();
dialog.addParm("sysparm_query", q);
dialog.setCompletionCallback(handleAdapterCreatedOrUpdated);
dialog.render();
}
function handleAdapterCreatedOrUpdated(test, sys_id, table, displayValue) {
location.reload();
}
Thanks,
Harsh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:22 AM
@EricG : Try with this script. I tested on my PDI and its working.
function openNewWin() {
ScriptLoader.getScripts('/scripts/classes/GlideModalFormSetWidth.js', function() {
var sysID = g_form.getUniqueValue(); // get the sys_id value from the change request
//Create and open the dialog form
var dialog = new GlideModalForm(new GwtMessage().getMessage("Title to be displayed on the popup message"),'cmdb_ci_outage');
dialog.setSize("modal-lg",300);
dialog.setPreference('sys_id','-1'); //-1 to get create new record
// dialog.setPreference('sysparm_view', 'name_of_the_view'); //Load 'create' view
dialog.setPreference('sysparm_query','short_description='+g_form.getValue("short_description")+'^task_number='+sysID); //copy the change sys_id to the parent field
dialog.setPreference("sysparm_link_less", "true");
dialog.setPreference('sysparm_view_forced', 'true');
dialog.setPreference('sysparm_clear_stack', 'true');
//Fuction called on feedback submit, to add success message and refresh Knowledge Feedback Task related list
dialog.setCompletionCallback(function(action_verb, sys_id, table, displayValue){
location.reload();
var feedTaskNum = '<a href="/cmdb_ci_outage.do?sys_id='+sys_id+'&sysparm_view=">' + displayValue +'</a>';
g_form.addInfoMessage( new GwtMessage().getMessage("Successfully created Table Record [name of the table]: {0}",feedTaskNum));
});
//Open the dialog
dialog.render();
});
}
Let me know if you have any questions for me.
Thanks,
Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 12:37 PM - edited 01-03-2025 12:38 PM
OK, not working for me.
I'm getting this error in the console window
GET scripts/classes/GlideModalFormSetWidth.js net::ERR_ABORTED 404 (Not Found)
If i look in the script includes, i don't have
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 03:09 PM
Maybe it's more like this?
https://www.servicenow.com/community/developer-forum/how-to-set-size-of-glidemodalform/m-p/1764636/h...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 08:22 PM
@EricG Have you tried this on personal instance ?
Also can you try to access this url, it contains the js libraries , this is ootb .
https://<YourInstanceID>.service-now.com/scripts/classes/GlideModalFormSetWidth.js
Can you try again with this script :
function openNewWin() {
var dialog = new GlideModalForm("Outage Task", "cmdb_ci_outage");
dialog.setSysID("-1");
var q = 'short_description=' + g_form.getValue("short_description") + '^task_number=' + g_form.getUniqueValue();
dialog.addParm("sysparm_query", q);
dialog.setCompletionCallback(handleAdapterCreatedOrUpdated);
dialog.render();
}
function handleAdapterCreatedOrUpdated(test, sys_id, table, displayValue) {
location.reload();
}
Thanks,
Harsh