- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 11:13 AM
Hello,
I have a workflow for a RITM that has a wait-for condition. The wait for condition is waiting for the user who the RITM is requested for to have their user record updated. If I manually update the user record and then go to the RITM and make any change the wait for condition works properly. I created a business rule that when the user record gets updated go to the RITM and make a change so that the wait for the condition will trigger without anyone needing to manually update the RITM. However, after adding the business rule and updating the user record I am getting a workflow terminated error message. Does anyone know how I can resolve this issue?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 01:29 PM
Hi Jared,
Since the workflow is on RITM table, it will only move forward in case there a manual change on the RITM, instead of updating the RITM with a business rule. Write an after business rule on the user table with the below logic.
runWorkflow_task();
function runWorkflow_task() {
var parentGr = new GlideRecord(sc_req_item);
parentGr.addQuery("requested_for", current.sys_id);
parentGr.query();
if (parentGr.next()) {
new Workflow().broadcastEventToCurrentsContexts(parentGr, 'update', null);
}
}
Hence whenever the user record is updated, the wait for condition will again trigger and check for the condition.
Let me know in case of any further queries.
Regards,
Deepankar Mathur

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 11:39 AM
Hi Jared,
Can you share your business rule script?
Regards,
Deepankar Mathur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 11:49 AM
(function executeRule(current, previous /*null when async*/) {
/////////////////////////////////////////////////////////////////////////////
// Update the RITM when a new probation user's employee id gets updated.
// This will trigger the workflow wait condition to check again and see the new employee id.
/////////////////////////////////////////////////////////////////////////////
var gr = new GlideRecord('sc_req_item');
gr.addQuery('item', '883dcb0fdbf10910a8ea9506f396191d'); //Probation New User item
gr.addQuery('requested_for', current.sys_id);
gr.query();
while(gr.next()){
gr.comments = 'New employees Employee ID has been added.';
gr.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 01:29 PM
Hi Jared,
Since the workflow is on RITM table, it will only move forward in case there a manual change on the RITM, instead of updating the RITM with a business rule. Write an after business rule on the user table with the below logic.
runWorkflow_task();
function runWorkflow_task() {
var parentGr = new GlideRecord(sc_req_item);
parentGr.addQuery("requested_for", current.sys_id);
parentGr.query();
if (parentGr.next()) {
new Workflow().broadcastEventToCurrentsContexts(parentGr, 'update', null);
}
}
Hence whenever the user record is updated, the wait for condition will again trigger and check for the condition.
Let me know in case of any further queries.
Regards,
Deepankar Mathur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 01:41 PM
Thank you, that made it work as intended. Do you know where I could go to learn more about the Workflow() and broadcastEventToCurrentsContexts()? Googling them and looking in the SN documentation isn't returning anything. I am just curious to know more about how to manipulate these workflows and to truly understand what the function is doing.
Regardless, thanks! I appreciate your help.