Auto Increment in Backend Workflow / A Bug?

All,

I have spent a few hours going around in circles trying to solve something that should be super simple. I can’t tell if what I’m encountering is a bug or a quirk of a NoSql backend (?) or a latency issue?

Lets say I have two datatypes on my database:

  • UniqueCount (with a single item as a number in it)
  • Messages (with an array of messages)

I am passing a list to a backend workflow with two steps.
Step 1: Look Up & Increment UniqueCount:unique-number for getting unique sequential integers. In this case, I say Search for “UniqueCount”: and increment it by referencing unique-count= unique-count+1 (pseudo code)

Step 2: Then I say, add another message to the Messages from the list of messages, and in the numbers field, use the unique count

In this way, if I pass

message1, message2, message3 as a list to the workflow
I should get:
Number: 1 Message: message1
Number 2: Message: message2
Number 3, Message: message3
Number 4, Message: message4

But it doesn’t work - it doesn’t seem to increment UniqueCount sequentially in a loop. It seems to do it in parallel or something - so I end up with something like:

Number: 1 Message: message1
Number: 1: Message: message2
Number: 1: Message: message3
Number: 3 Message: message4
Number: 3. Message: message5

If I increase the size of the list, this kind of janky numbering continues.

This makes “no sense” unless it is not an iterative process or there is a delay between updating it and retrieving it, which I suspect? Does anyone know a workaround? Must I create a recursive function API call / for loop to solve this? Looking at logs gives no clarity.

N.b. I’ve burned through several thousand WU just trying to get my head around this. I can’t fathom why auto-incrementing an integer is so tricky (?).

Hey @toduffy :wave:

Can you share a screenshot of your workflow so we can try to help out? Hopefully we can figure this out together. :blush:

This is an API Workflow as follows:



Producing data in the database as follows. Each of those messages should have a different number, incrementally, instead, something else happens that isn’t what I seek:

I think you are missing something like the max number. You might be able to do something like this:

Search for Count Duckulas each item’s OrderNumber MAX +1

This should give you the number that you are looking for I believe.

Is that what you are looking for?

Count Duckula only exists for one purpose - to give me unique incrementing integers.
There is only one row in the db.

If I use a workflow triggered by a button that:

Increments the number in Count Duckula’s first field
Then uses that number when adding a single message, this works perfectly

But in this case, if I pass 9 items to the workflow API to make multiple things, they don’t all get separate numbers. I’m guessing this must be a bug or nocode latency thing. I presume I can do some kind of loop too… but seems like a very non-optimal way to achieve something so simple.

As an interim workaround, I included a series of numbers in the list I was passing, then used regex to extract those and set them. This seems like a super long winded compute inefficient way to do something so simple - especially for anyone being charged by the WU.

If anyone knows how to get this to work without me writing a recursive workflow call - I would love to know?

Thanks for your suggestions J805.