Updating Wait for condition in the WF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
Hello, I have come across where I want to "stop" the WF in wf editor if a user does not have these two Booleans on the user profile(sys_user) are true at the same time. the wait for condition will check it the first time & if those two fields aren't true, it will stay stuck in the wait for condition which is fine, but later if the user has the required two Booleans = true it does not update the wait for condition and it's just stuck in the workflow & will not proceed.
If both of them are check the WF doesn't start again or rechecks, basically the wait for condition is still stuck even though the condition has been satisfied where both of the Booleans are true.
Has anyone have any tips or something to refer to, I researched some of the restart the workflow or a run script, but I have not had any luck.
I have tried timers and that too but I want it to happen instantly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Workflows only follow the transactions on the trigger record. If your wait for condition is scripted and conditional to values on another table you have to explicitly tell the workflow to continue. If wait for condition is waiting for something on current then check that the updates to [sys_user] are not done after calling setWorkflow(false) before the update.
For an example on how to continue a workflow you can check the Nudge ui action on [wf_context]:
runWorkflow_forContext();
function runWorkflow_forContext() {
var contextId = current.sys_id;
if (contextId != null) {
new Workflow().broadcastEvent(contextId, 'update');
}
}
You should be able to use the execute or update events, see snippet from wait for condition activity handler below:
onExecute: function() {
// stay waiting until true or fault
activity.state = "waiting";
this.onUpdate();
},
onUpdate: function() {
if (this._checkQueryCondition() && this._checkScriptCondition())
activity.state = "finished";
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
@HenryD ,
wait for condition activity only re evaluates when the workflows current record is updated...... so if your wait is checking values on the sys_user record (the two booleans) the workflow will stay stuck even after those fields become true unless the record on which the workflow is running gets updated again or you explicitly tell the workflow to re check......because it does not automatically detect changes on other tables......
Detailed post: https://www.servicenow.com/community/developer-articles/how-does-the-wait-for-condition-workflow-act...
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Technical Consultant/Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
your requirement is not clear.
share it properly along with screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
