{"id":877,"date":"2022-01-18T16:02:16","date_gmt":"2022-01-18T16:02:16","guid":{"rendered":"https:\/\/logicbuilder.integroscrm.com\/help\/?page_id=877"},"modified":"2022-08-02T18:42:19","modified_gmt":"2022-08-02T18:42:19","slug":"for-each-element","status":"publish","type":"page","link":"https:\/\/logicbuilder.integroscrm.com\/help\/for-each-element\/","title":{"rendered":"For Each Element"},"content":{"rendered":"\n<p><a name=\"abstract\"><\/a>Allows building loops to perform some piece of logic for each element of the collection or element of the array in input.It has two output control ports \u2013&nbsp;<strong>loop body<\/strong>&nbsp;and&nbsp;<strong>completed<\/strong>. Control flow will keep coming back to this operator until all the elements in the input have gone through the same path down the loop body port. When finished with all the entities or when there are no entities in the input, it runs the control flow to the control flow link that is connected to its completed control port.<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>Please see&nbsp;<a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/for-each-entity\/\" target=\"_blank\" rel=\"noreferrer noopener\">For Each Entity<\/a>&nbsp;for a detailed description of how loops work. The difference between <span style=\"color: #ec8f45;\">For Each Entity<\/span> and <span style=\"color: #ec8f45;\">For Each Element<\/span> is that <span style=\"color: #ec8f45;\">For Each Entity<\/span> works only with <span style=\"color:#ef6950;\">Entities<\/span> as input (runs the loop for each record), while <span style=\"color: #ec8f45;\">For Each Element<\/span> works only with <span style=\"color: #6888c9;\">Collection<\/span> or <span style=\"color: #6888c9;\">Array<\/span> as input (runs the loop for each collection element or each element of the array).<\/p>\n<\/div>\n\n\n<p><strong>inputs:<\/strong><\/p>\n\n\n\n<p>elements &#8211; input collection or array to walk through in the loop.&nbsp;Arrays elements are usually obtained from <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/get-array-elements-by-path\/\">Get Array Elements By Path<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-c7bec2ec17224a93aefcb942b91dae66-1024x298.png\" alt=\"\" class=\"wp-image-479\" width=\"923\" height=\"269\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-c7bec2ec17224a93aefcb942b91dae66-1024x298.png 1024w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-c7bec2ec17224a93aefcb942b91dae66-300x87.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-c7bec2ec17224a93aefcb942b91dae66-768x224.png 768w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-c7bec2ec17224a93aefcb942b91dae66.png 1521w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/figure>\n\n\n\n<p>Collection usually comes from <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/create-collection\/\">Create Collection<\/a> operator or <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/split-string-into-collection\/\">Split String Into Collection<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-f8af4bf177104c458dedbb4341c8004d.png\" alt=\"\" class=\"wp-image-481\" width=\"537\" height=\"173\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-f8af4bf177104c458dedbb4341c8004d.png 773w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-f8af4bf177104c458dedbb4341c8004d-300x97.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-f8af4bf177104c458dedbb4341c8004d-768x247.png 768w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-ee3cd08fda3343b3a0913b7b8ba76bdf.png\" alt=\"\" class=\"wp-image-480\" width=\"737\" height=\"180\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-ee3cd08fda3343b3a0913b7b8ba76bdf.png 983w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-ee3cd08fda3343b3a0913b7b8ba76bdf-300x73.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-51-ee3cd08fda3343b3a0913b7b8ba76bdf-768x188.png 768w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/figure>\n\n\n\n<p>break &nbsp;&#8211; connect control flow to this port, in order to break from the loop and move onto the operator, pointed to by &#8216;completed&#8217; control flow output. This port is often connected to one of the outputs of a Branch inside this loop&#8217;s body.<\/p>\n\n\n\n<p><strong>outputs:<\/strong><\/p>\n\n\n\n<p>completed &#8211; flow goes here and proceeds to the following operators once the operator runs out of elements in the input or when &#8216;break&#8217; control flow input is reached.<\/p>\n\n\n\n<p>loop body &#8211; flow goes here and proceeds to the following operator for each element in the <span style=\"color:#6888c9;\"><em>elements<\/em><\/span> input until either all of the elements are processed, or when &#8216;break&#8217; control flow input is reached. After that, control flow proceeds via &#8216;completed&#8217; port.<\/p>\n\n\n\n<p><span style=\"color:#6888c9;\">element<\/span> &#8211; one given element of the Collection or Array in the input of the current step of the loop.<\/p>\n<div style=\"text-align:left\" class=\"yasr-auto-insert-visitor\"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_877' class='yasr-visitor-votes'><div class=\"yasr-custom-text-vv-before yasr-custom-text-vv-before-877\">Click to rate this post!<\/div><div id='yasr-vv-second-row-container-fab94f9f0c6ee' \n                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-fab94f9f0c6ee'\n                                      class='yasr-rater-stars-vv'\n                                      data-rater-postid='877' \n                                      data-rating='0'\n                                      data-rater-starsize='24'\n                                      data-rater-readonly='false'\n                                      data-rater-nonce='fa81b01ba5' \n                                      data-issingular='false'\n                                    ><\/div><div class=\"yasr-vv-stats-text-container\" id=\"yasr-vv-stats-text-container-fab94f9f0c6ee\"><svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" \n                               class=\"yasr-dashicons-visitor-stats\"\n                               data-postid=\"877\" \n                               id=\"yasr-stats-dashicon-fab94f9f0c6ee\">\n                            <path d=\"M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z\"><\/path>\n                          <\/svg><span id=\"yasr-vv-text-container-fab94f9f0c6ee\" class=\"yasr-vv-text-container\">[Total: <span id=\"yasr-vv-votes-number-container-fab94f9f0c6ee\">0<\/span>  Average: <span id=\"yasr-vv-average-container-fab94f9f0c6ee\">0<\/span>]<\/span><\/div><div id='yasr-vv-loader-fab94f9f0c6ee' class='yasr-vv-container-loader'><\/div><\/div><div id='yasr-vv-bottom-container-fab94f9f0c6ee' class='yasr-vv-bottom-container'><\/div><\/div><!--End Yasr Visitor Votes Shortcode--><\/div>","protected":false},"excerpt":{"rendered":"<p>Allows building loops to perform some piece of logic for each element of the collection or element of the array in input.It has two output control ports \u2013&nbsp;loop body&nbsp;and&nbsp;completed. Control flow will keep coming back to this operator until all the elements in the input have gone through the same path down the loop body &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/logicbuilder.integroscrm.com\/help\/for-each-element\/\"> <span class=\"screen-reader-text\">For Each Element<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"tags":[],"class_list":["post-877","page","type-page","status-publish","hentry"],"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/comments?post=877"}],"version-history":[{"count":7,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/877\/revisions"}],"predecessor-version":[{"id":2032,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/877\/revisions\/2032"}],"wp:attachment":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/media?parent=877"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/tags?post=877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}