Tray's 'loop' connector offers 3 types of loops:
Loop List allows you to iterate through a list (aka array) of objects and will end when the list ends:
If your Loop List operation ends before you expect it to, check the length of the list.
Loop Object allows you to iterate through the keys of an object. It ends when there are no more keys.
If your Loop Object operation isn't working, check that it has an object with keys to iterate over.
Finally, the Loop connector also offers a Loop Forever operation. The Loop Forever operation works similarly to a while loop in most programming languages; it needs an ending condition if you intend for it to stop:
In this example, we use a Loop Forever operation to paginate through a list of Stripe invoices. When there are no more invoices, we break the loop:
The Break Loop step allows you to select the loop you want to break. If you forget to do this or select the wrong loop, you'll have unexpected results:
Comments
0 comments
Please sign in to leave a comment.