Redirecting to home page whenever clicking on cancel button, Buttn functionality is fine.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 04:36 AM - edited 05-29-2024 10:43 AM
function confirmCancellationNew() {
var msg = '';
var rcipFlag = true;
var flag = confirm('Cancelling a Request Item cannot be undone' + msg + ', would you like to proceed?');
if (flag == true) {
g_form.checkMandatory = false;
try {
//now ignore any mandatory variables
var allVariables = document.getElementById('variable_map').getElementsByTagName('item');
for (var i = 0; i < allVariables.length; i++) {
var item = allVariables[i];
g_form.setMandatory('variables.' + item.getAttribute('qname').toString(), false);
}
} catch (err) {}
gsftSubmit(null, g_form.getFormElement(), 'cancel_request_item_new');
} else
return false;
}
if (typeof window == 'undefined') {
cancelRequestItemNew();
}
function cancelRequestItemNew() {
current.comments = "Request was cancelled by " + gs.getUserDisplayName();
new Workflow().cancel(current);
current.u_cancel_flag = true;
current.stage = 'Request Cancelled';
current.state = '4';
current.approval = 'no_approval_required';
current.update();
new UIActionUtils().approvalsNoLongerRequired(current.sys_id); //Script Include to cancel approvals if any
action.setRedirectURL(current);
if (rcipFlag == true){
cancelSCTasks();
}
}
function cancelSCTasks() {
var num = "";
var grTASK = new GlideRecord('sc_task');
grTASK.addQuery('request_item', current.sys_id);
grTASK.addActiveQuery();
grTASK.query();
while (grTASK.next()) {
num += "," + grTASK.number;
grTASK.state = '4';
grTASK.active = 'false';
grTASK.update();
}
}
action.setRedirectURL(current);
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 08:51 PM
The code line
action.setRedirectURL(current);
is misplaced. Instead, move it inside function cancelRequestItemNew(). And also check if "current" is the right reference. Maybe you want to redirect to another record.