Hi everyone, do you use custom events in backend workflows ?
What for exactly ? They don’t seem useful to me when API workflows can achieve the same things with the additional features of scheduling and looping on a list, but maybe I’m missing something?
I suppose there is some process to invoke API workflow, and it’s a bit more complicated than triggering an event. Additionally, you don’t need to care about security context when triggering an event as it’s inherited from invoking workflow. Custom events are preferable when you need to isolate some piece of logic of a complex workflow for maintainability. I didn’t test it, but I also suspect that recursive actions with custom events run faster and cheaper in WU.
Thanks Vladimir, I think you’re right that the cost in performance would be lower when triggering an event rather than an api workflow.
Regarding security though, the API workflow will run with the same user who schedule it, and we can easily keep privacy rules enforced as well as not exposing this endpoint publicly, so I’m not sure there is much of a difference in that aspect ?
Agree with you for the logic isolation!
I don’t think we can run custom events recursively though ?
Another point I just thought of, the custom event will execute synchronously withint the workflow that invoked it whereas the scheduled api workflow will run independently on another thread I believe, which could be useful or not based on what needs to happen after the workflow/event is invoked.
Same way they have the ability on the front end to ensure that a series of actions completes before another action within the series starts…if you have steps 1-3 and then step 4 is trigger custom workflow, and in custom workflow you have 7 actions that need to complete before step 5 from the original series begins, then use custom workflow.
I have in backend API calls that run, that require authentication from User data, which has expiration dates, which need to be refreshed, so I check their expiry, then run custom workflow to get the refresh authentication values, then in original series after the refresh is complete I run the API call.