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-18-2022 10:27 AM
Hi,
What is the Cancel button expected to do? If it just needs to close the UI Page and return to your previous page, the you can use below snippet in HTML. No need of client script.
<button class="btn btn-default" onclick="window.history.back()" style="margin-right:10px;">Cancel</button>
Please let me know if that works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 10:34 AM
Hello @mdash
Thank you so much for your reply. When the Cancel button is engaged, it should remove any entries made on the UI page and return to the previous window. Even with modifying my script as you've suggested, when I test it and enter values in the fields and click 'Cancel' the fields are still updated on the form. Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:35 AM
Hi Nya,
Can you share your complete code here for more clarity? There might be something related to the save function.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 08:38 AM
Hello @mdash
Thank you so much for your reply. Please find the full code for the UI page below. I really appreciate your help!!
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 currentTable = 'x_namim_edrm_nos_patch_schedule_task';;
var sysIDList = RP.getWindowProperties().get('sys_id_list') || '';
</g:evaluate>
<input type="hidden" name="current_table" value="$[currentTable]" />
<input type="hidden" name="sys_id_list" value="$[sysIDList]" />
<table width="400">
<tr>
<td nowrap="true" valign="top" width="600%" height="100%">
<div class="col-md-8">
<span><b><font style="background-color:lightblue">${gs.getMessage('I confirm the application core functionality has been validated and deemed acceptable for use following this release. By checking this box I am signing off on validation.')}</font></b></span>
</div>
<tr>
<td>
<div class="mt-10" style="padding-left:15px;">
<label class="checkbox-label">
<label><b>${gs.getMessage('Validation Complete')}:</b></label>
<g2:ui_checkbox id="validation_complete" name="validation_complete" value="false" />
</label>
</div>
</td>
</tr>
</td>
</tr>
<tr>
<td>
<div class="col-md-8" style="padding-left:15px;">
<label><b>${gs.getMessage("Work Notes")}</b></label>
<textarea wrap="soft" autocomplete="off" rows="5" id="work_notes_update" data-length="4000" style="; width:150%; overflow:auto; background-color:LightGoldenRodYellow;" name="work_notes_update">${jvar_work_notes}</textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:right; padding-top:10px;">
<button class="btn btn-default" onclick="closeWindow()" value="false" style="margin-right:10px;">Cancel</button>
<button class="btn btn-primary" onclick="mass_updates()">Complete Sign Off</button>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function mass_updates(){
g_form.save();
GlideDialogWindow.get().destroy();
}
function closeWindow() {
GlideDialogWindow.get().destroy();
return false;
var urlOnStack = GlideSession.get().bottom();
response.sendRedirect(gs.getUrlOnStack());
}
Processing Script:
updateMutlipleRecords();
function updateMutlipleRecords() {
// gs.addInfoMessage('current_table - ' + current_table);
// gs.addInfoMessage('sys_id_list - ' + sys_id_list);
// gs.addInfoMessage('validation_complete - ' + validation_complete);
// gs.addInfoMessage('work_notes - ' + work_notes_update);
var choice = new GlideRecord(current_table);
if (sys_id_list) {
var selectedRecords = sys_id_list.split(',');
choice.addQuery('sys_id', selectedRecords);
}
choice.query();
while (choice.next()) {
choice.validation_complete = validation_complete;
choice.work_notes = work_notes_update;
choice.update();
}
}
var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);