OK and Cancel not working on ui page

surya123
Mega Guru

Hi All

My script is 

 

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>
Number  <g:ui_reference name="ritm" id="ritm" table="sc_req_item" completer="AJAXTableCompleter" />
User: <g:ui_reference name="user" id="user" table="sys_user" completer="AJAXTableCompleter"/>
</g:ui_form>
<table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="left" nowrap="true"><br />
<g:dialog_buttons_ok_cancel ok="return validateForm()" cancel ="return OnCancel"/>
</td></tr>
</table>

</j:jelly>

 

Client script

function onCancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
function validateForm() {

var x= gel("ritm").value;
var y= gel("user").value;
if (x== "" ||y=="") {
alert("Please provide data to submit the dialog.");
return false;
}
return true;
}

Ok and Cancel button dont work as expected.

1 ACCEPTED SOLUTION

Adding this in HTML made it work

<input type="hidden" id="cancelled" name="cancelled" value="false"/>

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Surya,

What error it gives? Did you try giving alert?

Is this custom UI page?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Yes its a custom Ui page. I need two reference fields. Then On population i have a processing script to run. But I see Ok and cancel button dont operate.

Though the alert to check validateform works. I dont see the cancel and ok button disappear when clicked 

Hi Surya,

So basically whatever user has entered in Number and User you need to fetch that in Processing script?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Adding this in HTML made it work

<input type="hidden" id="cancelled" name="cancelled" value="false"/>