Create "Number Custom Field" # of Cards? Running into Loops ?
Asked by Travis Austin:

Hello There,

I've run into a loop problem (quite literally) since I was trying to figure out how to create a number of cards based on a Number custom field.

My attempt at a solution was:  
Trigger: When the Number custom field is set to a value greater or equal to 1,  
Actions: Create a card, then decrease the custom field by 1.

Obviously, this ran me into a loop error after 3 cards were created as I could see in the Butler log, and I'm really running into a pickle here trying to figure out how I could do this. This functionality is crucial to our workflow as we will have a number of sub-projects called "ADU's" within our main project, and I simply need to create a card for each ADU after the main project reaches a certain stage.

We will never have any projects with over 10 ADU's. If we run into a loop, can't these command runs just add to our used command quota?

For reference - the Butler command is initiated from our 'Purchase' board when a checklist named 'Purchase Stage 4' is completed. The loop begins running from our board 'Board Transfer', trying to create cards in the board "ADU Projects".

I also tried making a checklist (using the same loop to add each checklist item) and then using the 'for each item in checklist" action, but I am still running into the same problem on the checklist item creation portion.

In the meantime, I see if Triggering separate Butler commands for each of the custom field values will work instead. I have a feeling I'm going to run into the same problem though.  
If there is a solution to this please let me know, I'm almost grasping at straws trying to get similar functionality here. Thank you so much for your help!


Answers:
author: milynnus
body: [@Travis Austin](/t5/user/viewprofilepage/user-id/4284036)

Just thinking out a possible solution. Have an added criteria like a cf is greater or = 1 on card with x label, remove label , create card, find trigger card, decrease the cf, add back label. Will that work?

comments: author: Travis Austin
body: Heya there,

The problem arises when the same function is called more than 3 times in a Butler Cascade (or being triggered by another Command that triggers the initial Action), so that solution wouldn't work; the command stops if the trigger for the command is retriggered within the same command. (Wow that was wordy hahaha)

I found a workaround luckily since I will not need more than 10 cards created at a time, so instead of using something like for-loop logic (which triggered the problem I ran into here), I had to manually make 10 separate functions that triggered if the Custom Field equaled a specific value (as to not trigger the same Command). Basically, a command if it equaled 10, a command if it equaled 9, 8, 7, etc.

It's a pretty screwy workaround, but it works, and that's all I really need right now. The only way for Trello to enable some functionality like this (to mitigate their servers being blasted, and the users blowing through their command quota) would be for them to develop Custom Field custom data validation, but I don't see that happening anytime soon. I don't blame them, it's a crazy complex feature that makes even me tremble just when I think about it hahaha.

For anybody looking at this in the future - The highest value is going to dictate how many commands you're gonna have to make (Each command is the same, except for the checks for each individual value in the trigger).

Thanks for the help though SGi!