Issue with Loop and display of list Using Salesforce flow

flow-screen-componentflowscreenloopvisual-flowsvisual-workflow

I have the below salesforce flow:

enter image description here

What the flow is trying to do:

  1. On the first screen get the Account name and account number
    enter image description here
  2. If Acc number = 1 then assign acc values to a record variable var_account1
    enter image description here

enter image description here
3. For default outcome, I assign acc name&number to a record variable var_account2

enter image description here

  1. Add var_account2 to a list
    enter image description here

  2. create a default account variable with Name=Default and Number = 1111. I use the same var_account2 to store it
    enter image description here

  3. Add var_account2 to list
    enter image description here

  4. Loop through the list and store the merge field into a text list
    enter image description here

  5. Display the content of the text list with account Name
    enter image description here

enter image description here

The problem: My issue is when going through the flow, I don't see all the account Name displayed after the loop. This is especially when the case when I assign account where the account number is not equal to 1 and when a default account is created.

All I want is to loop through the list of accounts and display only the account Name. This is to give the user a summary that what Account has been added. Is there any other way to do this?

Debug Mode:

enter image description here

enter image description here

enter image description here

In above step default Account doesn't show up

enter image description here

enter image description here

Now Acc3 , that I added doesn't show up

Best Answer

Your usage of loop is the culprit. This is what your current Flow says

  • For each item in your list_account variable
    • Add to your text collection variable
    • Go to the screen

You've never actually waited for the end of your loop.

What you want is

  • For each item in your list_account variable
    • Add to your text collection variable
    • After loop is finished (after last item)
      • Go back to screen

You need to make your assignment in the loop closed and then add a connector from the Loop element to the screen element for After Last Item.

enter image description here

Then, while you enter your information - it'll appropriately loop through the whole list (to assign your merge collection variable) before then going back to the screen.

enter image description here

Related Topic