Order Guide - Allow incomplete requested items?

alex2410
Tera Contributor

Hi All!

 

I have a requirement via an order guide with 3 catalog items.

 

Currently (and I believe ootb), when any one of the 3 Requested items are closed skipped or closed incomplete, it is auto updating the Request as closed incomplete.

 

Is there a way to prevent this on the Request state? So, if any ritm's are closed skipped or incomplete, do not cancel the overall Request?

 

Thank you,

Alex

 

#orderguide #catalog #process #request

 

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hi @alex2410 

By default (out-of-the-box), if any one of the RITMs is set to a "closed incomplete" or "closed skipped" state, the REQ record's state may also be updated to "Closed Incomplete."

To change this behavior and prevent the overall Request from being marked as "Closed Incomplete" when any RITMs are incomplete or skipped, you can modify or override the behavior using a Business Rule on the sc_request table.

Condition :-  state changes to Closed Incomplete


var ritmGR = new GlideRecord('sc_req_item');
ritmGR.addQuery('request', current.sys_id);
ritmGR.addQuery('state', '!=', 'closed_incomplete'); 
ritmGR.addQuery('state', '!=', 'closed_skipped');
ritmGR.query();


if (ritmGR.hasNext()) {

current.state = previous.state; // Reset the state back to what it was
}

})(current, previous);

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


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Pradnyesh
Kilo Sage

Hello @alex2410 ,

You can use below code for your requirement : 
Just gave order to maximum so it will run at the end.

Pradnyesh_0-1726225628284.pngPradnyesh_1-1726225650107.png

(function executeRule(current, previous /*null when async*/ ) {
    /*
        Below code is checking that if any RITM is in open or WIP under request then request state should be in process it will not change if any one is closed skipped or closed Incomplete.
    */

    var arr = [];
    var gr = new GlideRecord('sc_req_item');
    gr.query('request', current.sys_id);
    while(gr.next()){
        arr.push(gr.state);
    }

    for(var i = 0;i<arr.length;i++){
        if((arr[i] == 1) || (arr[i] == 2)){          // 1 = RITM state is open   &  2 = RITM state is Work In Progress
            current.state = 'in_process';
            current.update();
        }
    }

})(current, previous);


If above solution works for you then please mark my answer as Helpful !

Thank You !
Regards,
Pradnyesh.