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>
Hey 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?
Hey 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.
We do not have the ListV2 plugin installed, so I am sure that is what the issue is.
Thank you Mark
I am using the Glide Dialog popup window to display tasks associated with the selected business service, but since Aspen release a little issue developed. When placing my mouse on the hoverover icon against the record in the Glide Dialog Popup window, the preview appears below the Glide Popup Window making it unusable. Is there a quick fix for this?
Hmm, that seems strange. You really shouldn’t be able to hover over items in a glide dialog window at all. As far as I know, dialogs within dialogs aren’t supported. I think you should contact support on this one. Just don’t mention SNGuru or they’ll try to tell you it isn’t supported. 🙂
The strange thing is this used to work just fine, ultimately it is just a list of records displayed in a dialog. Without the hoverover preview, it makes the functionality almost useless and I might as well remove it. I will log a call with support, but surely there has to be a way to tell which window appears at the top.
I am having trouble with a popup for the user’s recent incidents. I want to display the last five incidents where the user is the caller. Everything works fine except that orderByDesc() does not seem to work in UI Macros and the same seems to be true for getRowCount(). This makes it very difficult to get only the last five incidents. I am having to run a GlideRecord Query before sending the query to the page so that I can find the 5th most recent date and include that in the query. Let me know if anyone has any ideas.
function showCIIncidents(reference) {
var call = g_form.getValue(‘caller_id’);
var date=”;
var gr = new GlideRecord(‘incident’);
gr.addQuery(‘caller_id’,call);
gr.orderByDesc(‘number’);
gr.setLimit(5)
gr.query();
while(gr.next())
{
date=gr.sys_created_on;
}
//Initialize the GlideDialog window
var query = ‘caller_id=’+ call+’^sys_created_on>’+date;
var w = new GlideDialogWindow(‘show_list’);
w.setTitle(‘Major Incidents’+date+’ ‘+query);
w.setPreference(‘table’, ‘incident_list’);
w.setPreference(‘sysparm_view’, ‘default’);
//Set the query for the list
var num = g_form.getValue(‘number’);
w.setPreference(‘sysparm_query’, query);
//Open the popup
w.render();
}
I think the problem is that ‘setLimit’ and ‘getRowCount’ are only available server-side. You should be able to accomplish this, but you’ll need to use a GlideAjax call to do it.
In the first exmaple can we set the size of the pop up window.
You can. I’ve added a note to the article above explaining how.
Mark
The setSize(WIDTH,HEIGHT) works great in IE however I am unable to get it to work in any other browser. Is there another method we can use to set the size that will work across multiple browsers.
Thanks
I just tested it without issue when I responded to your post yesterday. If you’re having an issue with the API you’ll need to contact ServiceNow. I don’t know any other way than what I’ve posted.
Hi Mark, I know this post is a little old, but it appears that if you have a long string of text the GlideDialogWindow does not wrap the text despite using the setWidth method. The glide_confirm, glide_confirm_basic, etc all specifically have a nowrap tag in the cell that displays the text.
We got around this by adding some table html code () to the beginning of our title preference:
dialog.setTitle("The A-Team");
dialog.setWidth(200);
dialog.setPreference('title', "</td></tr><tr><td>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn't commit. These men promptly escaped from a maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune. If you have a problem and no one else can help, and if you can find them, maybe you can hire the A-team.");
dialog.render();
Hopefully this helps some additional people running into the width setting issue!
Thanks Carleen!
Hi Mark,
The list that comes up donot have the usual list properties like sorting and export to Excel,pdf etc. Is it possible to enable these properties for this list?
Thanks
I’m not aware of any way to do that.
Hi Mark,
Is there a way to make an update to multiple records from the popup list that’s on a different table?
I created an UI Action that’s only a list choice (titled, “Add Asset to Requested Item). When I popup my list (of assets) I want to be able to add any selected assets in that popup to the parent requested item. I’m having trouble doing this because I am unable to reference the sysID of the form/sc_req_item in my UI action.
There’s no way with a standard popup list that I’m aware of.
I want a dialog popup from a UI action (or macro) showing a list of records. No drama so far.
However, when I click a record from the table, I want this to populate a certain field (a reference field on the incident form) much like it would when opening the dialog from the magnifying glass icon. I can’t figure out this part! Any help would be greatly appreciated.
I’m looking for this functionality too.
Hi Mark ,
When we open the dialog box is it possible to set a dynamic filter so that we can see what we want.
For ex i have this “Show Active Incidents” on the Requested for field in Incident,so when i click on this I will get all my Active incidents but is it possible that i can see others incidents too just by having a filter like we have a normal LIST.
Thanks
Divya
I don’t know of a simple way to do that with these methods currently.
Hi Mark,
I’m trying to use this feature to show a popup with HR Profile but it always assume the last view used in the HR Profile form even though I’m forcing the use of another view. Do you have any idea on how to resolve this?
If you’re forcing the view with a parameter as shown above and it’s not working then you’ve probably found a bug or some other configuration issue/conflict in your instance. You’ll probably want to talk to SN support to investigate.