Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Redirecting to home page whenever clicking on cancel button, Buttn functionality is fine.

Not applicable
 
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

Maik Skoddow
Tera Patron

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.