GlideDialog or GlideModal

kevincroom
Tera Contributor

We have an example business case where a user types "VPN" in the short description field then clicks on a UI Macro which then queries the sys_template table presenting them with the template they need to use to consult with the end user.   Upon clicking on the link the description from the template that was returned is copied into the current form's description.   I have mirrored the out of box show_incidents UI Macro which has been successful at rendering the template we are looking for but have been unsuccessful so far at copying data back to the form.

I've seen other's nearly accomplishing by using a UI Action, UI Page with Client Script.   My preference is to use a UI Macro to solve this problem.

Below is a sample of code I've been working on.

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />

<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>

<g:reference_decoration id="${jvar_n}" field="${ref}"

  onclick="showRelatedList('${ref}'); "

  title="${gs.getMessage('Show related templates')}" image="images/icons/tasks.gifx" icon="icon-tree-right"/>

<script>

// show related list

function showRelatedList(reference) {

try {

var displayValue = g_form.getDisplayBox(reference).value;

var title = 'Showing records related to: ' + displayValue;

var s = reference.split('.');

var referenceField = s[s.length - 1];

var query = referenceField + '=' + g_form.getValue(reference);

//var table = 'sys_template';

var gdw = new GlideDialogWindow('show_list');

gdw.setTitle(title);

gdw.setSize(750);

gdw.setPreference('table', 'sys_template_list');

gdw.setPreference('sysparm_query', query);

gdw.setPreference('title', 'A New Title');

function gdw.setLoadCallBack(function(iframeDoc){

var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;

dialogFram.addLoadEvent(function(){

var dialogFrame.g_form.setValue('description', short_description);

});

});

gdw.render();

}

catch (e) {

jslog('error showing related list');

jslog(e);

}

}

</script>

</j:jelly>

2 REPLIES 2

Jace Benson
Mega Sage

What's your question?



If it's weather to user GlideDialog or GlideModal, I know GlideModal is supposed to be a replacement for GlideDialogWindow and GlideWindow.



https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=r_GMODV3-GlideModal_S_B_N_N


"API Reference - Client Side


ServiceNow provides client-side JavaScript APIs allowing you to control aspects of how ServiceNow is displayed and functions within the web browser. This reference lists available classes and methods along with parameters, descriptions, and examples to make controlling the end user experience easier.


GlideModalV3


Provides methods for displaying a content overlay.


This is a fully-featured replacement for GlideWindow and GlideDialogWindow."


Michael Domke
Tera Guru

Did you ever figure out how to get the data from the modal list back to the form? I'm very interested as I have a similar idea for something I'm putting together.

Thanks,

Michael