{"id":875,"date":"2022-01-18T15:34:01","date_gmt":"2022-01-18T15:34:01","guid":{"rendered":"https:\/\/logicbuilder.integroscrm.com\/help\/?page_id=875"},"modified":"2022-06-10T10:00:41","modified_gmt":"2022-06-10T10:00:41","slug":"for-each-entity","status":"publish","type":"page","link":"https:\/\/logicbuilder.integroscrm.com\/help\/for-each-entity\/","title":{"rendered":"For Each Entity"},"content":{"rendered":"\n<p><a name=\"abstract\"><\/a>Allows building loops to perform some piece of logic for each entity in input. Works exclusively with Sugar Entities (e.g. Calls, Accounts, Cases, etc) in input.<\/p>\n\n\n\n<p>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 entities&nbsp;in the input have gone through the same path down the&nbsp;<strong>loop body<\/strong>&nbsp;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&nbsp;<strong>completed<\/strong>&nbsp;control port.<\/p>\n\n\n\n<p>Assume that you have 2 entities in the input port <span style=\"color:#ef6950;\">entities<\/span> in <span style=\"color:#ec8f45;\">For Each Entity<\/span>.&nbsp;Control Flow will go through links:<\/p>\n\n\n\n<p>1 -&gt; 2-&gt; 3 -&gt; 4 -&gt; 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5-&gt; 6<\/p>\n\n\n<p><a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-e408a5f73549446e9030c4adcf71df00.png\" rel=\"prettyPhoto\"><img decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-e408a5f73549446e9030c4adcf71df00-1024x483.png\" alt=\"\" class=\"wp-image-378\"><\/a><\/p>\n\n\n<p><strong>inputs:&nbsp;<\/strong><\/p>\n\n\n\n<p><span style=\"color:#ef6950;\">entities<\/span> &#8211; input&nbsp;records to walk through in the loop. Such records&nbsp;are usually obtained from <span style=\"color:#ec8f45;\">Retrieve Entities&nbsp;By&nbsp;Attributes<\/span> or <span style=\"color:#ec8f45;\">Retrieve Related Entities<\/span> operator.&nbsp;<\/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-50-5f2ac84235b84db2a5dcaf4adcf5b8ce-1024x279.png\" alt=\"\" class=\"wp-image-473\" width=\"639\" height=\"174\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-5f2ac84235b84db2a5dcaf4adcf5b8ce-1024x279.png 1024w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-5f2ac84235b84db2a5dcaf4adcf5b8ce-300x82.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-5f2ac84235b84db2a5dcaf4adcf5b8ce-768x209.png 768w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-5f2ac84235b84db2a5dcaf4adcf5b8ce.png 1093w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/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 &#8220;completed&#8221; control flow output. This port is often connected to one of the outputs of a <span style=\"color:#ec8f45;\">Branch<\/span> inside this loop&#8217;s body.&nbsp;<\/p>\n\n\n<p><a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-7f585873c015401f9112d84f6bbb35af.png\" rel=\"prettyPhoto\"><img decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-7f585873c015401f9112d84f6bbb35af-1024x406.png\" alt=\"\" class=\"wp-image-378\"><\/a><\/p>\n\n\n<p>In this example control flow will go through 1 -&gt; 2-&gt; 3-&gt; 4-&gt; 5 After 3 there is \u2018break\u2019 which means exit the loop:<\/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-50-a24789e5ca6f47cdaebd0edcc6d97096-1024x368.png\" alt=\"\" class=\"wp-image-476\" width=\"751\" height=\"270\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-a24789e5ca6f47cdaebd0edcc6d97096-1024x368.png 1024w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-a24789e5ca6f47cdaebd0edcc6d97096-300x108.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-a24789e5ca6f47cdaebd0edcc6d97096-768x276.png 768w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-50-a24789e5ca6f47cdaebd0edcc6d97096.png 1173w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/figure>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>Use &#8216;break&#8217; only when it is needed to stop the loop prior it process all entities in the input. If there is no need to terminate the cycle under certain circumstances, just leave &#8216;break&#8217; empty, and flow goes on the &#8216;completed&#8217; path when all entities are processed.&nbsp;<\/p>\n<\/div>\n\n\n<p><strong>outputs:&nbsp;<\/strong><\/p>\n\n\n\n<p>completed &#8211; flow&nbsp;goes here and proceeds to the following operators once all of the records are processed or when &#8216;break&#8217; control flow input is reached.&nbsp;<\/p>\n\n\n\n<p>loop body &#8211; flow goes here and proceeds to the following operator for each record in the <span style=\"color:#ef6950;\">entities<\/span> input&nbsp;until either all of the records are processed, or when &#8216;break&#8217; control flow input is reached. After that, control flow proceeds via &#8216;completed&#8217;&nbsp;port.&nbsp;<\/p>\n\n\n\n<p><span style=\"color:#ef6950;\">entity<\/span> &#8211; one given entity from the number of&nbsp;entities&nbsp;in the input&nbsp;of the current step of the loop.&nbsp;<\/p>\n<div style=\"text-align:left\" class=\"yasr-auto-insert-visitor\"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_875' class='yasr-visitor-votes'><div class=\"yasr-custom-text-vv-before yasr-custom-text-vv-before-875\">Click to rate this post!<\/div><div id='yasr-vv-second-row-container-69c0aa84de719' \n                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-69c0aa84de719'\n                                      class='yasr-rater-stars-vv'\n                                      data-rater-postid='875' \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-69c0aa84de719\"><svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" \n                               class=\"yasr-dashicons-visitor-stats\"\n                               data-postid=\"875\" \n                               id=\"yasr-stats-dashicon-69c0aa84de719\">\n                            <path d=\"M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z\"><\/path>\n                          <\/svg><span id=\"yasr-vv-text-container-69c0aa84de719\" class=\"yasr-vv-text-container\">[Total: <span id=\"yasr-vv-votes-number-container-69c0aa84de719\">0<\/span>  Average: <span id=\"yasr-vv-average-container-69c0aa84de719\">0<\/span>]<\/span><\/div><div id='yasr-vv-loader-69c0aa84de719' class='yasr-vv-container-loader'><\/div><\/div><div id='yasr-vv-bottom-container-69c0aa84de719' 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 entity in input. Works exclusively with Sugar Entities (e.g. Calls, Accounts, Cases, etc) 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 entities&nbsp;in the input have gone through the same path &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/logicbuilder.integroscrm.com\/help\/for-each-entity\/\"> <span class=\"screen-reader-text\">For Each Entity<\/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-875","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\/875","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=875"}],"version-history":[{"count":3,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/875\/revisions"}],"predecessor-version":[{"id":1708,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/875\/revisions\/1708"}],"wp:attachment":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}