- 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-24-2016 01:48 PM
Hi Michael,
I have the wait for wf event already registered in the workflow. I'm just having issues firing the event.
I've tried the script with my event name but it still doesn't fire. I have this in a script activity but doesn't seem to resume the other workflow.
This workflow is running on the sc_req_item table. The event is also running on the same table. is this correct or should the event run somewhere else?
Triggering WF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2016 02:20 PM
Can you try to insert into the script following?
fireWorkflowEvent(current,'workflow.Imscomplete');
function fireWorkflowEvent(recordGR, evt) {
var wf = new Workflow().getRunningFlows(recordGR);
while(wf.next()) {
new Workflow().broadcastEvent(wf.sys_id, evt);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2016 02:29 PM
Unfortunately, the script doesn't work trigger though it runs without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 03:07 AM
That's strange, it actually does work for us pretty well and we are triggering with that piece of code from a transform map, when we import some data from an integration.
Pity is that I cannot find where the events for workflows are logged, they are unfortunatelly not part of the event log table and I cannot find them neither on the wf_activity table...
Can you maybe try to simplify the scenario in the workflow and really make sure that it is the event triggering part and not something else ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 07:38 AM
Is it possible my setup is incorrect?
I have an order guide that creates two optional RITMs if they're checked. One (let's call it A) is the workflow that can generate a triggering event. The other two (1 & 2) are the workflows that would be triggered by A.
Workflow A would only trigger 1 and/or 2 if they're related to a particular request and should not trigger any other workflow activities that are unrelated. I'm not sure if that's the normal action.
Right now, if I test it out, if WF A is completed, WF 1 and/or 2 still continue to wait.
Is this the correct or "normal" way Wait for WF event should be used?