Sequential task generation

sunny13
Giga Expert

I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete and then move to next task.

I'm trying to achieve   this with a "wait for condition" since i also want to check the state = Resolved.

find_real_file.png

Also what happens is when i Resolve one task it "Resolve" my RITM as well it did not wait for another task to get generated   but as per i requirement i want my RITM not to get resolved / closed until all my tasks are resolved / complete

I'm not sure whether the issue is clear let me know if you require more details

1 ACCEPTED SOLUTION

yes I know that, What you have mentioned in the question was "I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete". So this can do that trick if closed complete is fine.


If you want to query only based on the resolved state then wait for condition should be used.


Slightly modify your code like,


var gr = new GlideRecord('sc_task');


  gr.addQuery('request_item',current.sys_id);


  gr.query();


  gs.log('TASK1 count:'+gr.getRowCount());


  while (gr.next()) {


  gs.log('TASK1 state:'+gr.state);


  if(gr.state != 6)


  {


  gs.log('TASK1 inside if');


  answer = true;


}


}


View solution in original post

11 REPLIES 11

Hi Sajin,



To wait till one task is Resolved/Closed complete .


          Check the checkbox in catalog task 'Wait for completion'. If checked, the workflow activity waits for the task to complete before continuing. If not checked, the task is created but the workflow proceeds.


Task Activities - ServiceNow Wiki



For Request item to be closed until all my tasks are resolved / complete , try the below code in a wait for condition before the end activity along with a set value activity to mark the request item as completed:



var tskRec = new GlideRecord("sc_task");


tskRec.addQuery('request_item', current.sys_id);


tskRec.addQuery('active', "true");


tskRec.query();


if(tskRec.next()){


    answer = false;


} else {


    answer = true;


}


Hi Ajai,



'Wait for completion' works only when the task is closed complete it doesn't allow the workflow to process when the state is Resolved.


yes I know that, What you have mentioned in the question was "I want to develop a workflow such a way that i want my workflow to wait till one task is Resolved/Closed complete". So this can do that trick if closed complete is fine.


If you want to query only based on the resolved state then wait for condition should be used.


Slightly modify your code like,


var gr = new GlideRecord('sc_task');


  gr.addQuery('request_item',current.sys_id);


  gr.query();


  gs.log('TASK1 count:'+gr.getRowCount());


  while (gr.next()) {


  gs.log('TASK1 state:'+gr.state);


  if(gr.state != 6)


  {


  gs.log('TASK1 inside if');


  answer = true;


}


}


Hey Ajai,



Thanks Bro that worked for me



Now i just want to make sure my RITM "state remains in "Open " till my second task is marked closed complete.


Ajai,



I changed the RITM state via a run script .



Thanks for your help.