Hi,
I need some help to do what i want.
For example, I have a data type “points” which contains 2 entries.
This data type has a “quantity” field
The first entry quantity = 30
The second entry quantity = 120
What I want to do is to subtract for example 100 from both entries :
I want to take the 30 from the first entry and the remaining 70 from the second entry.
In the end we get:
quantity of first entry = 0
second entry quantity = 50
Hi there, @samir.ahres… I would need to create an example to get all of the details right, but a recursive backend workflow is likely the way to go here, and I can see the workflow having at least three steps. The first step would evaluate the entry in question and subtract the entry’s quantity from that same quantity only when the quantity is less than or equal to the total number to subtract. So, using your example, the step would subtract 30 from 30 because 30 is less than 100. The second step would evaluate the entry in question and subtract the total number to subtract from the entry’s quantity only when the result of the first step is empty. So, given your example, this step would not run because the first step was able to run. Finally, the third step would call the backend workflow again only when the result of the first step is not empty, and the process would repeat with the next entry.
One of the details that would need to be worked out (and that I can see being tricky) is how to determine and pass the remaining number to subtract (in this case, 70) to the backend workflow each time it loops. I will leave that one alone for now, but I’m sure it could be figured out.
Anyway, those are some thoughts that come to mind on this one, and I hope it helps.
yes I misread
the problem is that I am as you say blocked to pass the remaining 70 to the next loop.
i think i can do this with creating temporary data type to save the remaining number
I had actually started to work through an example, and the path I went down was to have a field on the Points data type called previous quantity. Then, the first step of the backend workflow would set the previous quantity field to the item’s current quantity, and now you would have access to that quantity in the last step of the workflow (i.e., the step that runs the backend workflow again).
I think I have an example that would work, but I can’t test it because my sandbox app is on the free plan. Where are you stuck? If you are open to the idea of working through it together in your app, feel free to shoot me a link to your editor (privately), and we’ll see what we can do.