UI Page: Cancel Button Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 09:08 AM - edited ‎11-18-2022 09:09 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 08:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 08:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 09:29 AM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 10:40 AM
That worked!! Thank you so much for your help!! I really appreciate it!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 10:53 AM
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!!