SLA cancel condition is not working

nameisnani
Mega Sage

Hi Team , 

 

can anyone please help me on this issue , 

 

I have created SLA on sc_req_item table . 

 

pic 1 

nameisnani_0-1735486686229.png

 

pic 2 

nameisnani_1-1735486712718.png

 

pic 3 

 

nameisnani_2-1735486741457.png

 

 

I have tested this SLA , start , pause and stop condtions are working properly , the issue with cancel condtion . 

 

instead of cancel SLA stage is showing ' completed'  when ritm state is ' closed incomplete '

nameisnani_1-1735487042291.png

 

nameisnani_0-1735487000126.png

 

 

 

can anyone please help me on this issue on cancel conditon , what was the mistake , where i need to update please help me with the steps .

 

Thanks 

1 ACCEPTED SOLUTION

@nameisnani 

I can see the BR is an After BR. Please try changing it to a Before BR and see if that helps.

Thanks,
Rakesh.

View solution in original post

14 REPLIES 14

Hello @nameisnani 

Here is the screenshot of SLA configured for cancel condition

JuhiPoddar_0-1735535581821.png

As I said earlier there is no issue in your SLA configuration.

Steps to test the cancel scenario:

  1. Create a new request or open the RITM form where SLA is not closed/cancelled.JuhiPoddar_3-1735536683035.png
  2. Change the state to closed Cancelled/skipped, save the form and check the SLA.JuhiPoddar_4-1735536734554.png

     

  3. The SLA stage should be in cancelled state.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

@Juhi Poddar 

 

Thanks for quick help , 

 

There was Business rule configured on sc_task , and I am thinking because of that BR , SLA is delaying . 

 

nameisnani_0-1735537333248.png

(function executeRule(current, previous /*null when async*/ ) {

    //Update RITM State   
    var flag =0;
    var state=current.state;
    var gr = new GlideRecord("sc_task");
    gr.addActiveQuery();
    gr.addQuery("request_item", current.request_item);
    gr.query();
    while (gr.next()) {
    state = gr.state;
    if(state !=3 || state !=4|| state !=7){
//gs.addErrorMessage("Please close the sc_tasks to proceed to Resolved state");
//current.setAbortAction(true);
    flag =1;
    break;
    }}
    var ritmst = new GlideRecord('sc_req_item');
    ritmst.get(current.request_item);
    
    //Update ritm state similar to sctask
    //ritmst.stage = 'fulfillment'; // Update stage after SCTASK is reopened 
    if (flag==0){
    ritmst.state = current.state; 
    ritmst.setWorkflow(false);
    ritmst.update();
    ritmst.setWorkflow(true);
    }
    else {
    ritmst.state = state; 
    ritmst.setWorkflow(false);
    ritmst.update();
    ritmst.setWorkflow(true);
    }
    ritmst.update();
    var reqstate = ritmst.state;
    //Update Request State 
    var req = new GlideRecord('sc_request');
    req.addQuery('sys_id', current.request);
    req.query();
    while (req.next()) {
        req.state = reqstate;
        req.setWorkflow(false);
        req.update();
        req.setWorkflow(true);

        if (reqstate == 3) req.stage = "closed_complete";
        if (reqstate == 4) req.stage = "closed_incomplete";
        if (reqstate == 7) req.stage = "closed_skipped";
        req.setWorkflow(false);
        req.update();
        req.setWorkflow(true);

        if (reqstate == 3) req.request_state = "closed_complete";
        if (reqstate == 4) req.request_state = "closed_incomplete";
        if (reqstate == 7) req.request_state = "closed_skipped";
        req.setWorkflow(false);
        req.update();
        req.setWorkflow(true);
        req.active = "false";
        req.setValue("active", "false");
        //req.setWorkflow(false);
        req.update();
        //req.setWorkflow(true);
        
    }

})(current, previous);

 

There was more setworkflow was written because of that i think issue is happening , 

could you please provide me the correct or updated script so that i can update . 

Hello @nameisnani 

  • Sorry, this is not a OOTB buisness rule.
  • Additionally, this should not interfere with the SLA.
  • SLA is designed to work based on the state value in RITM table.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @nameisnani 

 

I agree with Juhi, but also why SLA in RITM , it is not best pratice and a good use case. Better create SLA On SC task level. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

the cancel condition is configured correctly.

Is this happening for all RITMs?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader