- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 05:24 AM
Hi Team,
I written following code in "wait for condition" in work flow to pause the workflow until to close all task records for particular request item, But this not working, even all the tasks are closed but still it is in wait for condition only. It is not moving to further activities.
All these tasks are created dynamically trough run script from inputs of list collector.
Any Idea or inputs can help me a lot
code:
var gRT = new GlideRecord('sc_task');
gRT.addQuery('request_item',current.sys_id);
gRT.addQuery('active',true);
gRT.query();
if(gRT.hasNext()){
answer = false;
gs.log('if'+gRT.hasNext());
}
else{
answer = true;
gs.log('else'+gRT.hasNext());
}
Thanks.
Developer CommunityDiscussExperts CornerCommunity CornerConnect
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:54 AM
That's a good point. Workflows only re-check when the record used against the workflow (e.g. RITM, change request) is updated. Updating child records isn't going to trigger the workflow on the parent record. To do this, you could force an update on the request_item when an update to the sc_tasl table is made.
An AFTER BR on the sc_task table something like this
(function executeRule(current, previous /*null when async*/) {
var parent = new GlideRecord('sc_req_item');
parent.get(current.request);
parent.setForceUpdate(true);
parent.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:12 AM
Hi Chuck,
I tried your code it is working for the first time when transition entering into wait for condition activity. It is printing the count in log, If i start closing the tasks and check the log count remains same it is not updating.Actually it is not printing new log at all. I hope workflow is not resuming to check the condition, any suggestions...?
Thanks for your great support.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:28 AM
Check to see if there is a business rule on task or change_task that has a statement using the setWorkflow(false) method. That could be shutting down business rules and workflows from operating as expected.
Use System Diagnostics> Debug Business Rules to enable BR debugging. When you update a record, you will be able to see which BRs have run. The workflow log may shed some light on it as well. Take a look there for any information as to what is running and what is not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:08 AM
Hi Ankur,
The code is working, It is printing values for first time when tasks are created, If I try to task close records on by one, this count is not updating in the log, even though after closing all the records, count record is not logging in the logs. Which means workflow is not triggering or re initiated, to check currently the wait for condition is valid or not. It is just checking only for the first time when transition entering into wait for condition. even after closing tasks this count is not updating in the log.
Thanks for your valuable time for looking into this issue.any suggestion regarding this..?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:49 AM
My bet is it does not re-run as you are probably not updating the ritm after closing tasks? Make an update to parent ritm (any field can be a hidden one) after closing each task see if that works. E.g. int field that keeps amount of active tasks or sth.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 07:54 AM
That's a good point. Workflows only re-check when the record used against the workflow (e.g. RITM, change request) is updated. Updating child records isn't going to trigger the workflow on the parent record. To do this, you could force an update on the request_item when an update to the sc_tasl table is made.
An AFTER BR on the sc_task table something like this
(function executeRule(current, previous /*null when async*/) {
var parent = new GlideRecord('sc_req_item');
parent.get(current.request);
parent.setForceUpdate(true);
parent.update();
})(current, previous);