How to return data from last step of a recursive workflow

This is another one of those Bubble dilemmas that seem so simple, but after hours of trial and error, I come up with nothing. I am trying to find gaps in sequential numbers in a list of things by running a recursive workflow. (This workflow is just a step in another API, which is called from a third API. This 3rd API needs to ultimately return the result from this recursive workflow. This adds extra layers of complexity to my dilemma.)

THE OBJECT
In a nutshell–and greatly simplified–what I am trying to do is run a loop to see if item #1 =1, Item #2=2, Item #3=3, etc. If, for example, Item #4=5, then there is a break in the sequence at item #4, and I need to return Item #4 to API 2, which will, in turn, return it to API 3, which in turn, returns it to the workflow that originally scheduled the API call. (The other APIs are necessary for parsing the original data to extract the items in the list.)

THE ISSUE:
I set up the recursive workflow so that it returns the index of the first item where the index doesn’t match the value.
image
This seems like it would work. In my case, it should return “4”, but instead it returns, “251953” or an equivalent number. My research suggests that that is the ID of the API? So,

  1. Without creating a new data type in my database, is there a way to return the data directly?
  2. If I do need to create a new data type, how do I set it up so that if 2 or 3 users executer the same action at the same time, they don’t overwrite each other’s results? (I assume you need to somehow reference the item’s ID. Do you also have to have a field for User?)
  3. If I do all of step 2, how do I let the original client-side workflow know that the item is ready? Since the recursive workflow is asynchronous from the original workflow, how do I trigger the workflow is finished? If I try to send a return from the last iteration to signal it is finished, I end up in the same dilemma: It returns “251953” or an equivalent number.

Am I missing something? Is there a much easier way to do this? (Especially a way to do it on the Client side, which in my case, is where it really belongs. It is being used for validating inputs.)

Not having a good For…Loop ability in Bubble is one of my biggest headaches.

Have you tried this for a front end loop? Simple looper (workflow repeater) Plugin | Bubble

I have not. I will give it a try.

1 Like

That worked perfectly! Thanks!

1 Like

Awesome! Glad that worked for you. :blush: