- 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:04 AM
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.
- 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:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2021 05:26 AM
Correct you have to make some update from problem task to problem to move the workflow.