Forum Academy Marketplace Showcase Pricing Features

[SOLVED] Workflow with Custom Event not working as expected

Hi @josh and @emmanuel,

I have a workflow event that creates an Approval thing for a related Request thing, and then triggers a Custom Event that performs a search on the Approval thing before running. This wasn’t working correctly and only after creating a second approval thing did the Custom Event fire.

I’ve since read a few posts on here and noticed that there is a “Trigger custom event when data changes” action, so I added a field to watch on the Request thing that gets updated after the creation of the approval thing, but this still didn’t work.

It’s like there hasn’t been enough time between the creation of the thing and the search of the thing to allow the Custom Event to trigger.

The use case I’m trying to achieve is: There are two Things: Request and Approval. A Request is created and then needs to be approved by 10% of related Approvers once the Request’s Status = “Ready for Approval”. At “Ready for Approval”, Approvers can approve, and once 10% approve, the Status of the Request needs to be changed. How can I accomplish this?

Yeah, so searches update in near-real-time, but not instantly. So if you create or modify a thing and then do a search later in that workflow (or a custom workflow triggered by it), you can’t count on the search picking up the change you just made.

What I might do in your case is to calculate the % before creating the new approval, taking the +1 into account manually. Ie, run a custom event with the condition: ([Search for approvals] : count + 1) / (total approvals) > 0.1. And then after you do that, create the new approval.

We may change this behavior at some point to create stricter guarantees around when searches are updated, but there’s performance tradeoffs to always waiting for them to be updated, so we’d have to see if we can do something smart to get the best of both worlds. For now, assume that you can’t count on them updating, but that they might, so do any logic that would come out differently depending on whether the search picked up your change prior to making the change.

OK, I’ll try to rework it. I have one other custom event doing a similar action also.

I looked into the Schedule Custom Event action. That would be nice if I could wait 10 seconds and then run it, but the documentation says if the page changes, then it won’t fire.

Not sure if using scheduled API would work?

Scheduling an API call should work as long as you don’t need that workflow to directly interact with any elements on the current page. That’s the main difference between a scheduled API and scheduled workflow: scheduled workflows start client-side in the browser, so they can modify the current page but won’t run if the page changes, whereas scheduled APIs are entirely back-end, so they run reliably but can only change data / send emails / etc.


Thanks for the help Josh! I got them to work. For one of them I just added a field to the Request to store the calculation on creation. Then I check the calculation in the Custom Event instead of searching and then performing the calculation in the Custom Event.

1 Like