# How to create a thing 'x' times, where x can vary?

Hi there,

I need to build a debt payment functionality to my app, where the user enters 3 pieces of information in 3 inputs:
1/A description of the debt/debtID
2/the amount of the debt remaining to be paid (input as a number)
3/the deadline at which the debt will have to be paid (date picker input)

I then have to create a thing in a data type called ‘budget’ with all the monthly instalments (where using simple maths, monthly instalment =total debt/months remaining , so budget has the following structure:
-Month
-Year
-Instalment amount
-Debt ID

The challenge I face is that depending on how long it takes to pay the debt, I will have to create more or less things. For instance, if the debt is \$1000, and the deadline is 4 months from now, I will have to create 4 entries (each entry with the instalment amount = \$250). Now, if the deadline is 10 months away, I will have to create 10 entries (with instalment amount = \$100 each time). Where i am struggling is, how to use worfklows in that scenario. I only know how to create a fixed number of things, and cannot figure out how. to manage the dynamic aspect of the number of things I need to create. Any suggestions would be highly appreciated. Thank you very much !

Any of the following 3 methods will work for creating an indeterminate number of things:

1. Recursive API workflow
2. Running an API workflow on a list
3. using the Data API bulk create endpoint

Both method 2 and 3 require first generating a list (it can be a list of anything).
Method 1 doesn’t require generating any kind of list.

Method 3 is by the the fastest and lowest in WU cost, method 1 is the slowest and most costly… although in your case it probably doesn’t matter much, so a recursive workflow might be the simplest method here.

2 Likes