I
‘ve been meaning to write about the different kinds of Glide popups available in Service-now for a while but haven’t really figured out a good way to show all of the different pieces that make them work. Instead of putting all of the information in one article I’ve decided to publish 2 or 3 different articles showing some of the different things I’ve done in the past. Look for more articles on Glide popup windows in the future. If you want to see all of the articles I’ve written about GlideDialogWindow and popups in Service-now just use the tags at the bottom of this article.
This article shows how you can pop open a list of records in Service-now using a couple of different methods. It also shows you how you could use a UI Macro icon to invoke either of these popup types.
The following scripts can be called anywhere where you can use client-side JavaScript. Most often these would probably be called from a UI Action with the ‘Client’ checkbox checked.
This first example shows how to pop open a list of major incidents in a GlideDialog window.
function showMajorIncidents() {
//Initialize the GlideDialog window
var w = new GlideDialogWindow('show_list');
w.setTitle('Major Incidents');
w.setPreference('table', 'incident_list');
w.setPreference('sysparm_view', 'default');
//Set the query for the list
var num = g_form.getValue('number');
var query = 'active=true^priority=1^number!=' + num;
w.setPreference('sysparm_query', query);
//Open the popup
w.render();
}
In some cases it may be necessary to open the popup in a separate window completely. This script opens a regular popup window containing a list of major incidents.
function showMajorIncidents() {
//Construct a URL for our popup window
var num = g_form.getValue('number');
var tableName = 'incident';
var url = tableName + '_list.do?';
url += 'sysparm_query=active=true^priority=1^number!=' + num;
//Open the popup
var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}
You can also use these functions in UI Macros. Here’s an example that pops open a window displaying high-priority incidents currently open for the selected CI. The script would need to be put in a UI Macro and that macro would need to be added to the ‘cmdb_ci’ field.
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:if test="$[current.getTableName() == 'incident']">;
<j:set var="jvar_n" value="show_major_incidents_${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showCIIncidents('${ref}')"
title="${gs.getMessage('Show major incidents')}" image="images/warning.gifx"/>
</j2:if>
<script>
function showCIIncidents(reference) {
//Get the name of the field referenced by this macro
var s = reference.split('.');
var referenceField = s[1];
//Get the value of the reference field
var v = g_form.getValue(referenceField);
//Initialize the dialog window
var w = new GlideDialogWindow('show_list');
w.setTitle('Major Incidents');
w.setPreference('table', 'incident_list');
w.setPreference('sysparm_view', 'default');
//Set the query for the list
var num = g_form.getValue('number');
var query = 'active=true^priority=1^number!=' + num + '^' + referenceField + '=' + v;
w.setPreference('sysparm_query', query);
//Open the popup
w.render();
}
</script>
</j:jelly>

Comments
Posted On
Oct 01, 2010Posted By
Scott BrickellHey Mark,
I was trying the “GlideDialog popup window” for returning a list as you did above. I’ve got it working with the exception that I don’t have the ui action drop down menu and the check boxes for each record. Here is what I’ve got:
dialog.setTitle('Crisis Events');
dialog.setPreference('table', 'u_crisis_list');
dialog.setPreference('sysparm_view', 'default');
var query = 'u_active=true'
dialog.setPreference('sysparm_query', query);
dialog.render();
Any suggestions?
Posted On
Oct 01, 2010Posted By
Mark StangerHey Scott,
Give it a try on /demo and see if you get different results. My guess is that you’re not using ListV2 but I’m not sure. Those elements aren’t anything that can be configured as part of the popup so it’s probably a larger system setting.
Posted On
Oct 04, 2010Posted By
Scott BrickellWe do not have the ListV2 plugin installed, so I am sure that is what the issue is.
Thank you Mark