Workflow activity 'Wait for Condition' always needs a 'Nudge'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2017 12:04 PM
I have the following 'Wait for Condition' script. When the step runs the first time the value is 'requested'. Whether it is 'approved' or 'rejected' the activity won't trigger when the approval/rejection is done and the task 'parent status approval' is updated.
I get the workflow to continue I have to go into the activity context for the RI and 'Nudge' the workflow, and then it continues on as it should. What am I missing? TIA
//*****************Need to check approval record*****************
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item', current.sys_id); ///'RITM0011604');
grTask.query();
if(grTask.next()) {
gs.log('BS Decision-' + grTask.approval);
if (grTask.approval == 'approved' || grTask.approval == 'rejected' ) {
answer = true;
}
}
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2017 11:51 AM
That's good news. But this workflow is in our company instance. ☹

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2017 11:53 AM
By any chance can you reproduce this on your personal dev instance. May be just create a sample workflow and see if you can trigger the workflow wait for condition when there is an update on the sc_task table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 12:11 AM
Hi there
I see also another issue: what if the sc_task is closed (not approved)?
I would check for active = true in the wait condition, then decode the approval in the next activity (you also do this, I guess).
Also, I would choose a slighly different approach to nudge the WF. There is an OOTB function to do this (we noticed timing issues with the approach recommended by Pradeep).
The Business rul on sc_task looks like this:
(function executeRule(current, previous /*null when async*/) {
"use strict";
// Fake-update the target record (sc_task --> RITM)
var grTarget = current.request_item.getRefRecord();
new Workflow().broadcastEventToCurrentsContexts(grTarget, 'update', null);
})(current, previous);
If this answer was helpful, I would appreciate if you marked it as such - thanks!
Best
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 02:06 AM
Hi Daniel,
We have exact similar code, in healthscan report we have observed that this code is running slow.
Is there any suggestions on can we optimize the performance.
Or could you please let me know the functionality of in detail.
broadcastEventToCurrentsContexts(grTarget, 'update', null);
Thanks and Reards,
Meenal