Close Parent Request if RITM has Complete and Cancelled Items

ivopetrow
Mega Contributor

Hello,

I have created a new business rule in order to change the parent request state to close when all

related RITMs are closed or canceled.

Please let me know if the script is ok

find_real_file.png

 

find_real_file.png

 

closeRequest();
function closeRequest(){

var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.addQuery('state', '!=', 3);
gr.query();
if (!gr.next()){
var sc_request = new GlideRecord('sc_request');
sc_request.addQuery('sys_id', current.request);
sc_request.query();
if (sc_request.next()){
sc_request.state = 3;
sc_request.update();
}
}
}

 

1 ACCEPTED SOLUTION

In workflow you can set the stage of an activity which then sets the stage attribute on the request item.  All of the out of the box examples use the "Completed" stage either on the end activity or just before the end activity.  Here is example from the procurement workflows:

find_real_file.png find_real_file.png

 

here is example from Service Catalog Item Request workflow:

find_real_file.png

 

Now changing your workflows won't address your existing 5000 records so a Fix script will be necessary to fix those.  But this will help with any new requests.

 

Please mark any post as helpful or the correct answer to your question if applicable so others viewing may benefit.

View solution in original post

5 REPLIES 5

Hi Michael,

 

Thanks for the suggestion.

I'm trying to figure out which table field to select when creating the new workflow?