Hi.
I too frequently want custom event return values.
If I treat custom events like a function, there are many cases where I need to pass the result of something generated inside to the next process.
Personally, the most common case is when I want to return the result of a “Create a thing” in a custom event.This is the case when a custom event is working as a factory.
Right now, I am passing data through a custom field in an element that is not directly related to the custom event, which significantly reduces maintainability.
@grace.hong
Please consider implementing this if possible.
Hi we have an ongoing project for this! Will keep you updated but we’re planning to work on this in the fall!
3 Likes
Other than storing values in a state, you can also put your next workflow as a different Custom Workflow and pass the Created Thing as a parameter of that Custom Workflow.
2 Likes
Great idea! Thanks, I’ll take advantage of that next time.
1 Like
+1 for this
My use case:
Need to have a function (custom event) that receive some user and go up the user hierarchy (user have a user boss) until it find the last one (big boss : ) and return it so I can continue my workflow. So it’s a custom/recursive/return data type of workflow.
1 Like
+1.
Our scenario (which I may be missing a better solution for) is an editor in a popup that has multiple “exit points” through user actions. Each exit point (close image, button for full submit, button to save draft etc) requires a different validation on the input as some allow more partial submission than others (so “can’t leave empty” won’t cut it).
In addition we also have there custom made “inputs” that simulate binding through workflows but aren’t really binded.
That said, naturally the exit points share the some complex validation logic, and we’d like to be able to maintain that set in one place that returns true/false.
You can actually do this already:
assuming the max iteration you want is 100
- custom event 1, parameter: user, count (number)
- trigger custom event 3, only when user’s boss is empty and count < 100, parameter: user
- schedule custom event 2 after 0 seconds, only when user’s boss is not empty and count < 100, parameter: user’s boss, count+1
- trigger custom event 4, only when count >= 100, parameter: user
- custom event 2, parameter: user, count (number)
- trigger custom event 3, only when user’s boss is empty and count < 100, parameter: user
- schedule custom event 1 after 0 seconds, only when user’s boss is not empty and count < 100, parameter: user’s boss, count+1
- trigger custom event 4, only when count >= 100, parameter: user
- custom event 3, parameter: user
- execute your final logic with the top boss
- custom event 4, parameter: user
- too much recursion, use the last user found and handle the error accordingly
start by triggering the custom event 1 with the innitial user and a count of 0.
2 Likes
I am curious as to why the max iteration is 100.
it’s just an arbitrary number, I would use something much lower or just change the data structure because I am wary of recursion in bubble.
2 Likes
Many thanks @dorilama !
I’m gonna try it
2 Likes
Hi - we just released the feature to return data on custom events! Learn more here: [New Feature] Return data on custom events
3 Likes