- 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 10:04 PM
Hi Chuck,
When I am using this code it is showing unique code violation, Is there any other way to update parent record.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 05:36 AM
Can you include a screenshot of the unique code violation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 09:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 01:11 PM
That's odd because that message seems to indicate that an insert is being done to try and create a new record with the same sys_id. Are you sure you have a parent.update() and not a parent.insert()? Please share the BR script with me that you have. (screenshots of the rest of the BR are also appreciated.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2017 08:16 AM
Thanks for your great support Chuck, I achieved this task by writing the following code:
(function executeRule(current, previous /*null when async*/) {
var wf= new Workflow();
var gr=new GlideRecord('sc_req_item');
if(gr.get(current.request_item)){
wf.runFlows(gr, update);
}
})(current, previous);
If I use below mentioned code I am getting duplication error.
var parent = new GlideRecord('sc_req_item');
parent.get(current.request);
parent.setForceUpdate(true);
parent.update();
Thanks