- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2021 05:01 AM
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;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2021 05:10 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2021 05:41 AM
Hi,
in that BR itself you can add that code I shared.
Script I shared will mimic an update on problem so that workflow knows update happened and will evaluate the wait for condition and proceed if all tasks are closed.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2021 01:16 AM
Use broadcastEventToCurrentsContexts instead of runFlows in above code