cancel conditon is not working in SLA on ritm table

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-1735527069678.png

 

 

pic 2 

nameisnani_1-1735527069575.png

 

 

pic 3 

 

nameisnani_2-1735527069674.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_3-1735527069638.png

 

 

nameisnani_4-1735527069681.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 .

9 REPLIES 9

Runjay Patel
Giga Sage

Hi @nameisnani ,

 

I have tested with same scenario, working fine for me.

Check the history of this record, it might be chance that first it went to complete and later it went back to close incomplete.

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

@Runjay Patel  Could you please provide the SLA configuration that you have configured? 

I will check on my SLA , 

Hi @nameisnani ,

 

See below.

RunjayPatel_0-1735536989478.png

 

RunjayPatel_1-1735537019614.png

 

RunjayPatel_2-1735537052343.png

 

RunjayPatel_3-1735537071692.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

 

 

@Runjay Patel 

nameisnani_0-1735539786023.png

nameisnani_1-1735539819717.png

 

 

see SLA is not cancelling , i don't know what stoping here .

 

Thanks for quick help , 

 

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

 

nameisnani_2-1735539872880.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 .