
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 11:40 AM
I've got a workflow that seems temperamental. Everything is working fine until I get to a "Wait for Condition" where it sometimes works and other times just sits there.
The Wait for Condition is waiting for the task that is generated by the workflow to be assigned, and then it is supposed to allow the workflow to advance. I have a script in the workflow that is checking for the task to be assigned, not sure if this is what's causing it or something else.
var gr = new GlideRecord('sc_task');
gr.addQuery('parent', current.sys_id);
//gr.addQuery('assigned_to', '!=', '');
gr.query();
if (gr.next()){
if (gr.assigned_to != ""){
answer = true;
}
else{
answer = false;
}
}
else{
answer = false;
}
Here is my workflow just for reference:
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 12:42 PM
So, I went and pulled up the BR that's referenced in that runFlows documentation. Looks like there's a new function that handles this now. Here's the script from that BR.
var gr = new GlideRecord(current.parent.getTableName());
gr.addQuery("sys_id",current.parent.toString());
gr.query();
if (gr.next()) {
new Workflow().broadcastEventToCurrentsContexts(gr, 'update', null);
}
I think you'll want to use the script in line 5 in your BR instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 11:45 AM
This is likely being caused by the fact that there's no BR or other functionality that triggers the Catalog Task's parent (RITM) to run its workflow. The condition check only runs when prompted--it isn't sitting there constantly running. I'd suggest creating a BR on the Catalog Task that makes use of the runFlows functionality to trigger the RITM's workflow to run when the Assigned To field is updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 11:46 AM
Also, this should be done in an after update business rule according to best practices as the Catalog Task itself isn't being updated but another table (RITM in this case) is potentially being updated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 12:30 PM
OK makes sense, I created a BR but cant seem to get it to work
Ive got it set to run on the sc_task table and the filter condition is :
Request item.item is JMP Software Licensing (The catalog request item)
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var wkfw = new Workflow();
wkfw.runFlows(current.request_item,'update');
})(current, previous);
When I assign the task it does nothing like it is not running the workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 12:36 PM
Can you try putting some log statements into the BR and the workflow's Wait For Condition just to ensure they're running properly? Also, you may want to add a condition to the BR so that it only runs when Assigned To changes and is not empty.