Need help: loop workflow duplicating output

I’m a bit baffled at what’s happening with my back end workflow:

The workflow aims at creating a copy of “cards” in the database, by copying 108 template cards. These template cards are marked by a unique number between 1 and 108 and their “template” attribute is “yes”.

My workflow then requires the initial index as input, which would be 1, then:

1. Finds the template card (template = yes and index = index)
2. Creates a new card using the information of the template card resulting from step 1. (This one is carefully marked as template = no).
3. Adds the result of step 2 to an array of cards in a “deck” item in another table of the database.
4. Calls the same API workflow, if the current index is < 108.

Now when I look at it again and again, I can’t see why it shouldn’t work. Yet, it copies all cards in duplicates. So I end up with 216 cards…

:thinking:

Step 1 in details:

Step 2 in details:

Step 3 in details:
image

Step 4 in details:
image

I checked that I have exactly 108 template cards (marked as yes), so it can’t be that the initial data is duplicated.

The workflow is completely linear: N calls N+1 one time unless N => 108. Even card n# 1 is duplicated. And when I look at the creation date of the cards, it’s not like 1, 2, … 108, 1, 2, 3, … 108, but rather 1, 1 ,2, 2, 3, 3, etc.

What could I have missed?

I’ve tested by adding a random string as an input on the initial call of the workflow, and it seems that the initial call is called twice for some reason. So the problem seems to reside in another workflow upstream.

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