Encapsulating a Function

As I develop my productivity app, I will have some sophisticated logic to determine the due date for a planned Action. This logic is something that must be available and work the same way on many pages within the system.

I have just begun developing the logic using workflow actions to set a series of custom states and reference the database to determine the best due date for an Action. It’s working great for the first page where it’s been implemented.

Attempting to copy this series of workflow actions to another workflow on another page has been a real pain. I tried creating a custom workflow and copying that to another page but references to the container for the custom states was lost on the new page so I practically had to rebuild the custom workflow on the new page.

I’m really lost for how to make this happen in Bubble. In languages I’ve known best from years ago, I would have this done in a global function that could be used anywhere in the app.

How can I encapsulate Bubble logic as in a function for use throughout the app? What I’ve been able to find regarding custom workflows hasn’t given me the understanding I need to make this work. I surely don’t want to start coding in JavaScript or any other language since the intent of using Bubble was to develop without writing code.

Any and all help is appreciated.

Laurence

Depending on the type of workflow you want to run, you may consider using API Workflows for this. Have you looked at those yet?

I’ve had some success putting logic routines into a reusable element that is then added to every page as a single item (the element has no design elements, so is just invisible.) You can then call those routines using the Trigger a custom event from a reusable element, action to fire things off as needed. The results of the logic are placed into custom states of the reusable element, which can then be utilized by the page itself as well as other elements on the page.

You can also use things like On page load to run common routines, but use this with care as you might end up with this running several times if you include this reusable element within other reusable elements!

1 Like

Andrew,

I tried an API workflow once with the purpose of assigning sequential numbers to items in a list. That didn’t go well.

I don’t recall what is possible in terms of passing parameters into and receiving results from an API workflow. I will check it out.

Thanks,
Laurence

1 Like

Thanks for this, Ken.

This sounds like it’s getting close to what I want to do. I vaguely recall reading about reusable elements early in my Bubble experience. I wasn’t ready to truly understand them. Now, I’ll give 'em a serious look.

Laurence

1 Like