- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2016 12:56 PM
I've been looking through any threads for Wait For WF event triggering but I don't seem to get or see how to script this out properly.
I have two workflows that wait for the "workflow.lmscomplete" event
I have script in another workflow to trigger the event"
new Workflow().broadcastEvent(context.sys_id, workflow.lmscomplete);
What am I missing?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 12:10 PM
OK cool so there is a linkage between the three, a parent sc_request.
In terms of fulfillment, is there a particular order these must follow: request item 1 before request item 2 before request item 3? If so you may need to have different WF Event names so each can wait for a specific step. So if request item 1 has to be completed before request item 2, then in request item 2's workflow you can have a WF Event waiting for "reqitem1_complete" and then in request item 3's workflow you can have a WF Event waiting for "reqitem2_complete" as an example.
So with this said the following code should work for you:
// Get all request items linked to parent request
var reqItem = new GlideRecord("sc_req_item");
reqItem.addQuery("request", current.request);
//Exclude current request item from query
reqItem.addQuery("sys_id", "!=", current.sys_id);
reqItem.query();
while (reqItem.next()) {
// Get running workflows for the current request item
var wf = new Workflow().getRunningFlows(reqItem);
while(wf.next()) {
new Workflow().broadcastEvent(wf.sys_id, "ENTER YOUR EVENT NAME HERE");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 12:17 PM
Thanks Michael!
I'll make some changes shorty and see if works. Request item 2 and 3 would start at the same time so it should be fine to fire both one event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 12:37 PM
Worked perfectly! I appreciate the help and patience!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 12:43 PM
Awesome glad you got this working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 06:40 AM
Thank you for this post, very helpful. I was working on setting off a WF Event when a Catalog Task's state was set to Closed/Complete. I would like to share some info that may help someone in the future:
According to the SN API on getRunningFlows(), both the input parameter and return values are Glide Records. So if you are like me and using a business rule that is watching the Catalog Task [sc_task] table, the 'current' object will be the the catalog task record. So you will have to feed the function the RITM that the Catalog Task belongs to in order to get the running wf, which is the WF running on the RITM in my case. https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_WF-getRunningFlows_GR
Question:
Where/what table do I look at to see if my event fired? I used the Event Registry to register my event and Ive looked at the Events [sysevent] log and in the Executing Activity [wf_executing] and it doesnt show up at all. I believe you can use the broadcastEvent() function and send it an empty event field and it will still trigger the wf to run. So did I do something wrong with my event or am I looking at the wrong place?
Any help is appreciated!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2019 02:43 AM
This thread is already closed, and I am not sure if this was the main mistake.
But the event name must be put in apostrophes ("" or '').
BR
Dirk