Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

when i cancel sc_task's , sla is not getting canceled

Devi D
Tera Expert

Hello Community,

 

Post Cancelling the SCTASK, the associated RITM and sctaks's are getting cancelled and task SLA is getting updated with stage as 'cancelled' but it does not get cancelled and the workflow of the task_sla is also still running and in the sla stop time is not getting updated.

after business rule on sc_task , when iserted/updated with conditions state changes to cancel and task criticality is not true

var sctask = new GlideRecord('sc_task');

    var gr = new GlideRecord('sc_req_item');

    if (gr.get(current.request_item)) {

        if (current.u_cancellation_choice == '1' && current.u_task_criticality != "true") {

      gr.u_fulfiller_cancellation = true;

            sctask.addQuery('request_item', current.request_item);

            sctask.addEncodedQuery('stateIN1,2,9,10,11');

            sctask.query();

            while (sctask.next()) {

                sctask.state = 8;

             sctask.active = false;

                sctask.u_cancellation_choice = current.u_cancellation_choice;

              sctask.setWorkflow(false);

                sctask.update();

          var taskgr=new GlideRecord('task_sla');

            taskgr.addQuery('task',sctask.sys_id);

            taskgr.query();

            while(taskgr.next()){

                taskgr.active = false;

taskgr.stage='cancelled';

taskgr.update();

               

            }

               

            }

            gr.state = 8;

            gr.stage = "Request Cancelled";

gr.update();

        }

    }

    // Add your code here

})(current, previous);

1 REPLY 1

AshishKM
Kilo Patron

Hi @Devi D , 

Please share the SLA configuration for cancel state and workflow diagram, have you configred the RITM cancel state execution path in workflow.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution