Modal UI Page redirecting to itself on OK or Cancel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 10:20 PM
Hi All
I am working on a UI action to allow itil staff to create a new caller if the person doesn't exist in the sys_user table. it all works well, except my modal UI page redirects to itself on submit and on cancel.
I am using
<g:dialog_buttons_ok_cancel ok='okButton()' cancel='processCancel()'/>
//Cancel button script
function processCancel(){
GlideDialogWindow.get().destroy();
}
After my dialog spawns, if I hit either OK or Cancel
it then redirects to a version of itself in a full screen:
I've tried using gs.setReturnURL and gs.setRedirectURL and a few other things i've found via google, but the behaviour never changes.
full scripts below:
UI Page:
HTML
<g:evaluate var="jvar_taskId" expression="RP.getWindowProperties().get('sysId')" />
<input type="hidden" id="hidden_sys_id" value="${jvar_taskId}"></input>
<g:ui_form>
<table width="700">
<tr>
<td>
<g:form_label>Enter User's Name</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_name" id="extusr_name" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>Enter User's Phone Number</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_phone" id="extusr_phone" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>RIW Number</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_riw" id="extusr_riw" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>Enter User's Company</g:form_label>
</td>
<td>
<g:ui_reference label="" name="extusr_company" id="extusr_company" table="core_company" mandatory="true"/>
</td>
</tr>
<tr id="dialog_buttons">
<td colspan="2" align="right"><!-- Pull in 'dialog_buttons_ok_cancel' UI Macro for submit/cancel buttons. 'ok' option will call the 'validateComments' Client script function from the UI Page-->
<g:dialog_buttons_ok_cancel ok='okButton()' cancel='processCancel()'/>
</td>
</tr>
</table>
</g:ui_form>
Client Script:
//OK Button script goes here
function okButton(){
var sysid = hidden_sys_id.value;
var name = extusr_name.value;
var phone = extusr_phone.value;
var company = extusr_company.value;
//var manager = extusr_manager.value;
var riw = extusr_riw.value;
//time for some AJAX
var ga = new GlideAjax('newExtUser');
ga.addParam('sysparm_name', 'createExtUser'); //ajax function
ga.addParam('username',name); //pass name into ajax
ga.addParam('userphone',phone); //pass phone
ga.addParam('usercompany',company); //pass company
ga.addParam('userriw',riw); //pass riw number
ga.addParam('hidden_sys_id',sysid); //pass sysid into ajax
ga.getXML(myCallBack); //process response
}
function myCallBack(response) {
//Dig out the 'answer' attribute
var ajaxcomplete = response.responseXML.documentElement.getAttribute('answer');
alert(ajaxcomplete); //alert the result to make sure all is well.
GlideDialogWindow.get().destroy(); //Close the dialog window
}
//Cancel button script
function processCancel(){
GlideDialogWindow.get().destroy();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 03:57 AM
Hey @Kai Tingey ,
Usually it works just by adding this after the "destroy()" in the UI action
action.setReturnURL(current);
I know you said "gs.setReturnURL and gs.setRedirectURL"
try using action instead gs.
if it helps let me know 🙂
Regards,
Nicolas Piveta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 03:37 PM - edited 07-12-2023 03:39 PM
Hi Nicolas,
Thanks for the response. Unfortunately that didn't work either. I've tried action.setReturnURL(current) and action.setRedirectURL(current)
i also tried
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 01:00 PM
Did you find an answer for this ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 03:00 PM - edited 12-05-2023 03:00 PM
yes it is working now.
I basically just re-did the entire thing from scratch and it worked. If i had to guess what part of it was causing the problem, is that in the new version i left the jelly code in the HTML - i think I stripped it out the first time because i didn't think i needed it.
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:evaluate var="jvar_taskId" expression="RP.getWindowProperties().get('sysId')" />
<input type="hidden" id="hidden_sys_id" value="${jvar_taskId}"></input>
<table style="width:700px;">
<tr>
<td>
<g:form_label>Enter User's First Name</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_fname" id="extusr_fname" mandatory="true" size="40" />
</td>
</tr>
<tr>
<td>
<g:form_label>Enter User's Last Name</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_lname" id="extusr_lname" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>Enter User's Phone Number</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_phone" id="extusr_phone" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>RIW Number</g:form_label>
</td>
<td>
<g:ui_input_field label="" name="extusr_riw" id="extusr_riw" mandatory="true" size="40"/>
</td>
</tr>
<tr>
<td>
<g:form_label>Enter User's Company</g:form_label>
</td>
<td>
<g:ui_reference label="" name="extusr_company" id="extusr_company" table="core_company" mandatory="true"/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:right;padding-top:10px;">
<button class="btn btn-default" onclick="processCancel()" style="margin-right:10px;">Cancel</button>
<button class="btn btn-primary" onclick="okButton()">Ok</button>
</td>
</tr>
</table>
</j:jelly>
Client Script:
//OK Button Script
function okButton(){
var sysid = hidden_sys_id.value;
var fname = extusr_fname.value;
var lname = extusr_lname.value;
var phone = extusr_phone.value;
var company = extusr_company.value;
//var manager = extusr_manager.value;
var riw = extusr_riw.value;
if (fname == ''){
alert('First name is required');
return false;
}
if (lname == ''){
alert('last name is required');
return false;
}
if (phone == ''){
alert('Phone number is required');
return false;
}
if (company == ''){
alert('Company is required');
return false;
}
//time for some AJAX
var ga = new GlideAjax('newExtUser');
ga.addParam('sysparm_name', 'createExtUser'); //ajax function
ga.addParam('userfname',fname); //pass name into ajax
ga.addParam('userlname',lname); //pass name into ajax
ga.addParam('userphone',phone); //pass phone
ga.addParam('usercompany',company); //pass company
ga.addParam('userriw',riw); //pass riw number
ga.addParam('hidden_sys_id',sysid); //pass sysid into ajax
ga.getXML(myCallBack); //process response
}
function myCallBack(response) {
//Dig out the 'answer' attribute
var ajaxcomplete = response.responseXML.documentElement.getAttribute('answer');
alert(ajaxcomplete); //alert the result to make sure all is well.
GlideDialogWindow.get().destroy(); //Close the dialog window
action.setRedirectURL(current);
}
//Cancel button script
function processCancel(){
GlideDialogWindow.get().destroy();
}