Use of GlideDialogWindow with UI Page - pass sys_id of record

Alex Macdonel
Tera Expert

We recently upgraded to Geneva from Eureka, migrating Knowledge from v2 to v3 has been fairly painless but we want to keep using our customized kb_view_customer UI Page available for a while as it has some custom views and fields that our Service Desk uses; for this I was thinking of creating a UI Action on the incident form called 'View Article' that will open a dialog window with the article that's attached to the incident.  

Is there a way to pass a sys_id to a GlideDialogWindow to open a record? I've been looking at this page: Displaying a Custom Dialog - ServiceNow Wiki but it doesn't describe what I want to do.

Has anyone done something similar?

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Sure, just use:



gdw.setPreference('sys_id', 'sysid of record');



It should add a url parameter for the sysid which you can use in the ui page.



You might also just consider opening the article in a new window/tab.


Hi Brad Tilton,



This is not happening:



gdw.setPreference('sys_id', 'sysid of record');



this is navigating to another URL, URL of my UI Page.!!


Please suggest any other way, to pass sys_id to setPreference method and show a record in glide dialog window in a UI Page.


Niranjan Danda
Tera Contributor

Hi Brad Tilton,  ayush512

 

I have  a  similar  issue where  i'm  having ui action which opens a dialog window. I am passing the sys_id of the current record and trying to  update the same record with the values entered in the dialog box. But after submitting the dialog box, it is redirected to the url of my ui page.

 

Here is my code in UI action:

 

UI action:

function sendEmail(){

//Initialize and open the Dialog Window
var sysid = g_form.getUniqueValue();
var dialog = new GlideDialogWindow("notification_update");dialog.setTitle("Notification Preview");
dialog.setPreference("sysid", sysid);
dialog.render();
}

Here  is my code in UI page:

 

html:

<?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:ui_form>
<g:evaluate var="jvar_sysid"
expression="RP.getWindowProperties().sysid"/>
<table border="0" width="100%">
<tr>
<td>
<g:ui_multiline_input_field name="notes" label="update" mandatory="true" />
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
<input type="hidden" id="task_sys_id" name="task_sys_id" value="${jvar_sysid}"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>

 

Client script:

function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
var data = gel('notes').value;
// g_form.setValue('description', data);
// g_form.save();
return true;
}

 

processing script:

var text = notes;
createRecords();
function createRecords() {
var app = new GlideRecord("incident");
if(app.get(task_sys_id)){
app.description = text;
app.update();
}
}
//response.sendRedirect('incident.do?sys_id='+task_sys_id);
var urlOnStack = gs.getUrlOnStack();
response.sendRedirect(urlOnStack);

 

 

Please let me know so that i can fix my script.

 

Thanks,

Niranjan.