RITM should start only after another RITM is closed complete

RudhraKAM
Tera Guru

I have a order guide in which when a request is raised it will create 2 RITMs ( 2 different catalog items ) my requirement is 

test A catalog item  ritm should be finish until then test 2 catalog item RITM should be on pause , the one way i am thinking of doing it is to put a wait condition on test 2 workflow and check if the request have test 1 catalog item then wait until its finish , and the code follows as below , there is some issue with code can some one help me with this code 

var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.addQuery('cat_item', "99fb579bdbbb73401e49f9051d96191f");
gr.addQuery('state',"3");
gr.query();
gs.log(" For RITM " +current.number +" the ROW Count is " +gr.getRowCount() );
if(gr.getRowCount() == '1'){
	answer = true;
}

 

and also please suggest me if you have any other scalable solution 

1 ACCEPTED SOLUTION
8 REPLIES 8

Allen Andreas
Administrator
Administrator

Change:

gr.addQuery('state',"3");

to

gr.addQuery('state', 3);

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks allen ,,update the state , still same issue  workflow is stuck in test 2 ,, is my script logic correct ?

checking for Request and checking for catalog item test 1 and state is closed complete .

find_real_file.png

RITM 1 is closed complete 

find_real_file.png

 

Test  2 is still waiting 

find_real_file.png

 

 

find_real_file.png

Wait for conditions are only checked/updated when the current record is updated. Your script is fine but it's not running the check in the wait for condition because nothing has changed on the current record. You can either add something in to the workflow on the first ritm to update the state or something on your second ritm or write something in to the master request wf.

I had this issue recently but i had a whole series of ritm's that needed to be triggered at different times so i built a custom request workflow, triggered it by creating one ritm with a scripted order guide and then created the rest when i needed them via script. This might be a bit complex for your requirements if you only have 2 ritm's but worth considering if you have more going on than you've written here.

Thanks David , this is just a draft but we have multiple catalog items , i will try  your solution