workflow is getting stuck here and not moving even after the task has cloed

lakng
Tera Contributor

here we have an issue in the workflow , as per the flow once the 1st task has closed / closed no response the next task has to be created. but after 1st task closed no response the workflow is still waiting for in the "wait for condition".

this wait for condition will check if any manually created tasks are still open or not. if all closed then it has to move further. 

here the closed no response state is -9

here the code used in the wait for condition.

answer=testCondtion();
function testCondtion(){

var prbTaskCloseComplete = new GlideRecord("problem_task");
prbTaskCloseComplete.addEncodedQuery('problem='+current.sys_id+'^stateIN3,4,7,8,-9^short_description=SDD to Provide CHI RCA Approval');
prbTaskCloseComplete.query();
gs.info('---Test Condtion----');
if(prbTaskCloseComplete.getRowCount() > 0){
return true;
}
else{
gs.info('---Test Condtion----'+'false');

gs.info(prbTaskCloseComplete.getRowCount());
return false;
}

}

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Workflow wait for condition will only work when

1) Update happens on same table on which workflow runs

In your case you are checking problem_task table and workflow is running on problem table

So you should mimic an update on problem via after update BR on problem_task

BR: Active [Changes To] False

Script:

(function executeRule(current, previous /*null when async*/) {

var wf = new Workflow();
var ri = new GlideRecord("problem");
if (ri.get(current.problem)) {
wf.runFlows(ri, 'update');

}
})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Pranesh072
Mega Sage
Mega Sage

Workflow will execute/check the activities when insert/update/delete operations happens on workflow table., in you it maybe problem table.

 

So have to make some update operation on problem record.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Workflow wait for condition will only work when

1) Update happens on same table on which workflow runs

In your case you are checking problem_task table and workflow is running on problem table

So you should mimic an update on problem via after update BR on problem_task

BR: Active [Changes To] False

Script:

(function executeRule(current, previous /*null when async*/) {

var wf = new Workflow();
var ri = new GlideRecord("problem");
if (ri.get(current.problem)) {
wf.runFlows(ri, 'update');

}
})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

we have an existed before update BR on Problem task table ,  which will set task Active = false when the task state changes to Closed no response

can we have one BR for both purpose?

means after the task closed no response, update should happen in the parent problem record and move the workflow further

Correct you have to make some update from problem task to problem to move the workflow.