Do arithmetic for items from # selection

I need to dynamically set the number for the :items from # selection, but it doesn’t look like any of the arithmetic operators are available. Is there another way to do this?

Basically I need to do something like “:items from #limit + 1” (where limit is a dynamic value)

Yeah, precompute “limit+1” and shove it in a custom state (this will be a separate workflow step) and then you can use that custom state as the variable value.

(This Issue of “right hand side” operators being limited in Bubble IS just crazymaking.)

Basically, whenever you compute limit, also compute another_limit as limit+1 and stash that somewhere.

Yep, that’s basically the workaround I’m trying to implement. Though because I’m doing this in an API Workflow, it’s not as straightforward.

Ah! Ummm… I think I accidentally stumbled upon a workaround for that recently. (But I need to research to re-uncover what that was…)

However, the “non-hacky” workaround is this:

Presumably, API Workflows don’t need custom states as they have the database (perma-storage). So, in the workflow, you can create a new thing (of whatever type you need) and reference its unique ID (via “results of”) to delete it when done with it.

Obviously this slows things down over temporary (in-memory) storage, but it seems Bubble guarantees us no bits in an API Workflow…

Apologies for the vagueness of this answer, but I did stumble across a potential solution (it may have related to unused optional arguments OR “return data from an API”… but I feel like there’s a way to (perhaps unintentionally) set, store and retrieve a value in API Workflows using Results of… a previous step.).

If that’s so, it may be fragile (subject to being fixed as a bug), but currently extant.

1 Like

Thank you Keith, don’t worry I completely understand.

I was trying to create it as a Custom Event within API Workflows (so that it is a reusable action) and found out I can’t trigger another API Workflow inside a Custom Event. So having said that, the best way to do this seems to be to create it as an API Workflow and then trigger another API Workflow to do the arithmetic and then use the result of that step as the “item from #” value.

1 Like

Interesting approach! (BTW, I get that “limit” may be a truly dynamic list-type value, BUT if you are passing limit to your API Workflow, just ALSO pass limit+1 (as some other key name) and… presto, problem solved.)

I only post that here for folks who might not have thought of that. I’m supposing you’ve thought of that and it does not work on your use case.

Actually, I just might have to use that approach of passing limit+1 (since it doesn’t look like I can use the result of the API Workflow trigger). My only concern is that I now have to pass responsibility to the caller to make sure they are aware of that and also if I decide to change that it would require changing it in a few places.

I think I have it, just needed to create a caller API workflow which calls the actual API Workflow with the incremented values.

Did a few tests and I’m unable to trick Bubble into doing what’s required either… Ugh. Yeah, pass the value with the addition already done. It’s ridiculous that we can’t have a LITTLE BIT of temp memory in API Workflows…

This topic was automatically closed after 70 days. New replies are no longer allowed.