https://www.activepieces.com logo
b
When the user select the "for each" element the piece loop itself on every item of the array. Another idea would be by adding a check box which execute the piece for each item :

https://cdn.discordapp.com/attachments/1146427171099902042/1151779561370026035/apcheck.jpg▾

m
This is interesting
b
May I start the development ?
a
Hi @bastienme I like the direction of this idea but I think we can shape it more first if you don't mind it
m
@bastienme how you would implement it?
Also what if the user selects two for each in the same action
What would be the behavior
b
Hey ! Sorry for the big delay I thought about a simpler solution which is to add a little 'Settings' section at the end of an action that has at least one array key as input. In this section there would be a toggle 'Run for each elements of the array' and a dropdown field where we would select the array we want to loop on so there won't be any problems with multiple 'for each' selection. It would look something like this : https://cdn.discordapp.com/attachments/1151779561877544980/1164093649953501194/image.png?ex=6541f5b1&is=652f80b1&hm=fc47357e5603035446b0d2807815c08cc8a551ffb408bcffa7dd854681799f27&
I haven't thought about the implementation in detail yet, but here's what I thought: In packages/shared/src/lib/flows/actions/action.ts I would add two properties to PieceActionSettings a boolean "forEachChecked" and an array which would contain the selected array In packages/ui/feature-builder-right-sidebar/src/lib/edit-step-sidebar/edit-step-form-container/edit-step-form-container.component.ts I would set the two properties in the store in the createNewStepSettings function In packages/backend/src/app/flows/step-run/step-run-service.ts In the create function at the switch step, when the ActionType is a Piece I would add something to check the boolean property and the array property and, if there is an array, it loops on the executePiece function changing the parameters at each loop. I'd like to know what you think and how you'd like me to manage this feature 😄