UI Page: Cancel Button Not Working

Nya Valdez
Kilo Guru

Hello Community,

I'm having an issue with my cancel button not working on a UI page I've built. When I click on the button, it copies any field values I've inserted into the record. If anyone can please take a look at it and let me know what I've missed, I'd greatly appreciate it. It should be fairly simple ... Here is my code:

 

HTML Script: 

 

<button class="btn btn-default" onclick="closeWindow()" style="margin-right:10px;">Cancel</button>

 

Client Script:

 

 

function closeWindow(){
		GlideDialogWindow.get.destroy();
		var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);
}

 

14 REPLIES 14

Hello @Nya Valdez ,

you can do one thing 

 

try to put this piece of code in your cancel function 

function closeWindow() {
document.getElementId('validation_complete').value="";
document.getElementId('work_notes_update').value="";
GlideDialogWindow.get().destroy();
 return false;
 var urlOnStack = GlideSession.get().bottom();
 response.sendRedirect(gs.getUrlOnStack());
}

Let me know if this works 

 

Hope this helps 

Mark my answer correct if this helps you

Thanks

Hello @Mohith Devatte 

THANK YOU so much for your reply. I tried adding the extra lines to blank out the fields in the client script as you've suggested but unfortunately I am still getting the same result where the fields are being updated despite me clicking on the Cancel button.  Should I be looking at the processing script to do this? Please advise.

@Nya Valdez my bad i gave the wrong script can you try the below one 

function closeWindow() {
document.getElementById('validation_complete').value="";
document.getElementById('work_notes_update').value="";
GlideDialogWindow.get().destroy();
 return false;
 var urlOnStack = GlideSession.get().bottom();
 response.sendRedirect(gs.getUrlOnStack());
}

 

Hope this helps 

 

@Mohith Devatte 

That worked!! Thank you so much for your help!! I really appreciate it!!!

Hi @Mohith Devatte 

By doing that it only actually clears the field values whereas I need it to actually function as a cancel button (where nothing has changed on the form).  In other words, if the checkbox is selected already but a user was updating the work notes only - then the checkbox should still be selected.  Can you please instruct me on how to achieve that?

Thank you so much for your help so far Mohith!!! I really appreciate it!!