function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Susan Ross-WentworthSusan Ross-Wentworth 

visual flow loop stops after only one record

I have created a visual flow which uses a loop to count the number of address objects which are related to a specified contact so that an automatic task will be generated if a contact is found to have more than one address.  My fast lookup returns the correct addresses, and I have an assignment element which, on each iteration of the loop, should add 1 to a number variable within my flow (the variable having stared with a default value of 0).  My fast lookup returns two records, so my loop should increase the value of my number variable by 2, but it doesn’t.  My variable only increases by 1, as if my loop is only counting the first record in the collection instead of every record in the collection.

flow steps

loop element

assignment element

loop results
StevenKTVStevenKTV
I had a similar problem which was solved by connecting the last element of the loop (in your case the screen) back to the loop element. Does that solve the problem?
Susan Ross-WentworthSusan Ross-Wentworth
That worked! I had thought a loop acted more like a decision element and needed two outcomes, but connecting the assinment back to the loop fixed the issue, and I've been able to successfully put other types of loops in other flows.  Thank you, StevenKTV!
StevenKTVStevenKTV
Great! The way to apply a loop isn't really obvious indeed... But glad I could help.