Wait for Condition in Workflow Not Proceeding After Manager is Added
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 09:37 PM
Hi everyone,
I am working on a ServiceNow workflow where I need to check if a Line Manager exists for the requested user. If a manager is missing, the workflow should:
1️⃣ Change the state to "Transform"
2️⃣ Trigger a notification via an event
3️⃣ Wait until the manager is added
4️⃣ Once the manager is added, update the state to "In Progress"
5️⃣ Rollback to the first step to recheck for the Line Manager
6️⃣ If the manager now exists, proceed with the workflow
Issue Faced:
- The workflow gets stuck at the "Wait for Condition" (WFC) step even after updating the manager field.
- The state changes to "Transform" and triggers the notification correctly.
- However, when the manager is added and the record is updated, the workflow does not move forward.
- I'm using Rollback to Activity to return to the initial manager check, but it does not seem to re-evaluate properly.
Anyone, Help me out work on this. Here, I'm Giving the condition for WFC to check:
answer = true;
var LineManager = current.u_requested_for.manager.sys_id;
if (!LineManager) {
gs.log('No Line Manager found - Waiting for update');
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:13 PM
the workflow wait will wait and listen for update on the current record to check the script and not on some other record
So you will have to use after update business rule on sys_user table
Condition: Manager Changes and Manager is not empty
Script:
check if this user is present in "u_requested_for" field of your table
If yes then get the active workflow context and propagate the update to that workflow so that it evaluates the condition and proceeds
Something like this in after update BR
(function executeRule(current, previous /*null when async*/ ) {
var wf = new Workflow();
var rec = new GlideRecord("yourTable");
rec.addQuery('u_requested_for', current.sys_id);
rec.query();
if (rec.next()) {
wf.runFlows(ri, 'update');
}
})(current, previous);
Also update your workflow wait script as this
answer = true;
var LineManager = current.u_requested_for.manager;
if (LineManager == '') {
gs.info('No Line Manager found - Waiting for update');
answer = false;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 01:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 02:02 AM
yes the workflow will continue as it got an update broadcast and it will evaluate the condition
Since condition became true it will proceed.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader