- 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-18-2017 08:18 AM
I'm glad you got your answer. Thanks for posting your solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 03:44 AM
Hi Chuck,
Even I am facing similar issues. But even after following above steps, iam not able to get it worked. Please guide me if any changes required in the scripts.
I put a wait for condition in RITM workflow which waits until a field changes on a different table[u_t_pa01_sr_enter_dc]. This particular table will have a string field which stores RITM number [Not a reference field]. Somehow automatically wait for condition is not moving forward even after field on the custom table changes. Below are my wait for condition and Business rule:
Wait for condition:
var service = new GlideRecord('u_t_pa01_sr_enter_dc');
service.addQuery('u_number',current.number.getDisplayValue());
//service.addNotNullQuery('u_return_code');
service.addQuery('u_return_code', '!=', 0);
service.query();
if(service.hasNext()){
answer = true;
}
Business rule:
(function executeRule(current, previous /*null when async*/) {
forceReqItemUpdate();
function forceReqItemUpdate(){
var wf = new Workflow();
var gr=new GlideRecord('sc_req_item');
gr.addQuery('gr.number',current.u_number.getDisplayValue());
gr.query();
if(gr.next())
{
wf.runFlows(gr,'update');
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 11:51 PM
Hi
var parent = new GlideRecord('sc_req_item');
parent.get(current.request);
parent.setForceUpdate(true);
parent.update();
But it seems like setForceUpdate is not allowed in scoped app. So I've tried
var wf= new global.Workflow();
var gr=new GlideRecord('sc_req_item');
if(gr.get(current.request_item)){
wf.runFlows(gr, 'update');
}
Thanks to both of you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 06:21 AM
Hi Chuck,
Please ignore the above ask. It was my silly mistake if u see the query Instead of just number, I have put it as 'gr.number'. Still I dont understand, how I could do such a simple silly mistake.
Thank You

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2017 08:07 AM
I'm glad you caught your issue. Don't feel bad, you're not alone.