Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Repeating Field changes again and again after RITM gets cancel

Community Alums
Not applicable
 
 
created Cancel ui action for sc_req_item and it working fine but in activity log it is showing 3 time that RITM got cancel?
 
any specific reason
 
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);



 

 

PradeepPatel1_0-1717002932782.png

 

1 REPLY 1

James Chun
Kilo Patron

Hi @Community Alums,

 

It's most likely that other processes such as Flow/Workflow or BR are applying the same changes.

 

I can see there is about 10 10-second delay before the second message, which could be from a Flow/Workflow running against the RITM.

Try running the Script Tracer to identify where the messages are coming from - https://docs.servicenow.com/bundle/washingtondc-application-development/page/script/debugging/concept/script-tracer.html

 

Cheers