+ Start a Discussion
goravsethgoravseth 

Displaying lists of data from a Sobject Collection in a flow (visual workflow)

I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field.

If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3].

Is there any way to get the flow to produce something along the lines of:

Name1, Value1
Name2, Value2,
Name3, Value3,

in a display text field?

If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that.

Thanks

(Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J)
Best Answer chosen by goravseth
SalesforceYodaSalesforceYoda
The trick here is getting the other non-Id values out of the sObject Collection, and to do that, you'll need a loop. Where it gets really hairy is getting it laid out correctly. I haven't built this yet, it's entirely theoretical, but here's what I would attempt.
  • First, make a new variable (we'll call it varDisplayText) to hold all of your text.
  • Then, in your loop, pass the Collection to a standard sObject Variable.
  • From there, use an Assignment element to Add (not equals!) the first value of the first column to varDisplayText.
  • Then (and I think you can do this in the same Assignment element, I am pretty sure it will do it in order), use varDisplayText again but instead of using Equals, use Add, and add the text string ", ".
  • Add another line in the same element (or a new Assignment element if necessary), use varDisplayText again, with Add, then the first value in your second column.
  • Add another line in the same element (or a new Assignment element if necessary), use varDisplayText again, with Add, then the comma text string again, but with a line break character afterwards.
  • Point back to your loop so you can get the next set of values in your collection.
When the flow runs, it should do the Assignment with the add, which functions as concatenation, for each row, creating a different row of text.

I am REALLY not certain this would work, but it's what I would try; it works on paper. Otherwise, I think you're limited to a VF page here.

All Answers

SalesforceYodaSalesforceYoda
The trick here is getting the other non-Id values out of the sObject Collection, and to do that, you'll need a loop. Where it gets really hairy is getting it laid out correctly. I haven't built this yet, it's entirely theoretical, but here's what I would attempt.
  • First, make a new variable (we'll call it varDisplayText) to hold all of your text.
  • Then, in your loop, pass the Collection to a standard sObject Variable.
  • From there, use an Assignment element to Add (not equals!) the first value of the first column to varDisplayText.
  • Then (and I think you can do this in the same Assignment element, I am pretty sure it will do it in order), use varDisplayText again but instead of using Equals, use Add, and add the text string ", ".
  • Add another line in the same element (or a new Assignment element if necessary), use varDisplayText again, with Add, then the first value in your second column.
  • Add another line in the same element (or a new Assignment element if necessary), use varDisplayText again, with Add, then the comma text string again, but with a line break character afterwards.
  • Point back to your loop so you can get the next set of values in your collection.
When the flow runs, it should do the Assignment with the add, which functions as concatenation, for each row, creating a different row of text.

I am REALLY not certain this would work, but it's what I would try; it works on paper. Otherwise, I think you're limited to a VF page here.
This was selected as the best answer
goravsethgoravseth
Great strategy, will be fun to test it out, and will keep you posted on how it goes. Cheers
goravsethgoravseth
Worked well! 

I had issues including spaces when adding text elements to the variable in the assignment, so instead I used a text template, which is a bit easier to manage, and was able to add the text template to the DisplayText variable in the loop.

To insert a line break at the end, I had to create a constant w/ value of <br></br> (found that from stackexchange (http://salesforce.stackexchange.com/questions/10354/visual-workflow-creating-paragraphs-and-double-line-breaks))

A few additional notes: make sure to include any fields you want to include in the text template in your fastlookup / sobject variable.  I had issues using a currency formula field that involved calculations, but was able to include a cross object formula field that just displayed text.  I might end up going visualforce anyways in order to better display the info, but its cool to be able to do this!
goravsethgoravseth
The issue w/ the currency calculation formula was that i had not included all the fields used in the formula in the sobject variable.  Fixed!
SalesforceYodaSalesforceYoda
Awesome, glad to hear it worked!
Jeff BergerJeff Berger
Hi All! Stumbled across this and I have this very same need. @goravseth I'd love a little clarification on how you used the Text Template. I admittedly haven't used the Text Template resource before and I'm not sure how exaclty you used it in conjunction with the varDisplayText as suggested by @SalesforceYoda. (PS, love your blog, @SalesforceYoda!) Any chance you'd be willing to post a screenshot of this portion of your completed flow, @goravseth?
goravsethgoravseth
Hi Jeff Here are some screenshots w/ details http://goravseth.clarify-it.com/d/k2gkhe Let me know if this helps! All credit to Yoda!
goravsethgoravseth
Hi Jeff Are you looping through a collection of records (sobject collection)? If so, that is strange. If not, then you shouldnt need a loop. Post a screenshot of your flow.
Jeff BergerJeff Berger
Hi @goravseth, thank you so much for posting. It worked like an absolute dream! I had been having an issue but it was because I forgot to draw the arrow going back to the loop from the assignment element. Once I did that everything clicked into place! My flow now loops through all of the "children" (Contacts) on an account (based on a "Relationship in the Household" field) and then displays the children with their info on my next screen! Thanks again!
goravsethgoravseth
Great - i forgot to mention that was a 'two way' arrow [😊] glad you figured it out.
Max PaqMax Paq
goravseth and SalesforceYoda,

Thank you both this will become very useful!
Peanutman21Peanutman21
@goraveth - The screenshots you provided for this were extremely helpful! Thank you for doing this.
So when I have an arrow from Loop > Assignment > Screen, I get one record to return. When I have an arrow from Loop > Assignment, and then another arrow from Assignment back to Loop, and then the 'End of Loop' arrow from Loop > Screen, I get no results. Any ideas as to why I either get back one row, or no rows, but not multiple rows as expected?
Max PaqMax Paq

@peanutman21

Can you post a screenshot of your flow?

I would think if you can display 1 value in the loop and not all values afterward either you are trying to display the test template and not the variable or the assignement element does something like : displayText equals textTemplate instead of displayText add textTemplate.

Also, I found out that if you want to save this variable into a record you need a rich text field.

Peanutman21Peanutman21
Hey @Max Paq! Thanks for having a look at this. Hopefully the image comes through OK. I believe my assignment is correct since I am using 'add' not 'equals'. Perhaps my screen which is displaying the results is wrong since I am displaying the text template and not the variable? However, when I changed my screen to use the variable instead of the text template, my results displayed 'truetruetruetruetrue'. 
Let me know what you think. Thanks! 

User-added image
 
Max PaqMax Paq
ok, on your screen you are displaying the text template ({!TT_FastLookup}. Try to display your variable {!VARDisplayOpportunities}.
Peanutman21Peanutman21
When I display the variable instead of the text template on my screen, when I run the Flow, what returns is the word 'true' instead of the data from the Opportunity record. Let me know what you think. Thanks!
Max PaqMax Paq

My bad should hvae looked at your assignment. you should assign the text template to the variable:


{!VARDisplayOpportunities} ADD  {!TT_FastLookup}
 

 

Peanutman21Peanutman21
HOLY COW! It works! I think my problem was I was displaying the text template rather than variable. That was the one screen not included in Goravseth's screenshot You the man!
Side question: I am guessing I can use the data captured in the text template in an email to someone?
Thanks again!
goravsethgoravseth
awesome glad y'all could resolve this will try to see if i can update the screenshots to highlight that the variable is what stores the info, the text template just populates it. cheers
Gavin GuinaneGavin Guinane
I created a video to show you how I did this. Feedback welcome of course. https://vimeo.com/150903234
goravsethgoravseth
Most awesome! Thanks for sharing this.
goravsethgoravseth
@gavin the record lookup within a loop will cause your flow to hit soql query gov limits and fail if there are more than 200 records in the lookup.

as you have included these fields in your fast lookup, they are accessible in your loop sobject variable, so you should be able to use varRecords.FieldName in your text template instead of using a record lookup inside your loop and creating variables for each field.

Have you tried using the loop sobject variable fields instead of running a separate lookup?  If so what issue did you run into?
Gavin GuinaneGavin Guinane
That's a good point @goravseth. The issue I ran into with the "outer" fastlookup was that it wasn't retrieving the non-ID fields of the account records. I saw somewhere else that this was a known issue and that a superfluous "inner" lookup was necessary :-(.
goravsethgoravseth
Gotcha. Must be a new-ish issue as I didn't run into that when building this out originally. The team decided to use a totally different approach so we never ended up using it but will try and test to see if it still works, as I was just using the fast lookup, no inner lookup.
Peanutman21Peanutman21
HeyGavin! Can you post a link to the known issue you ran into? I am moving forward with implementing the original design goravseth has above (thanks so much goravseth!) and so far it is working for me without the need for the record lookup within the loop.  
Gavin GuinaneGavin Guinane
@Peanutman21  - I found others wih my problem. It was: FLOW_ELEMENT_ERROR| The flow failed to access the value for <object.fieldname> because it hasn't been set or assigned. Here (https://developer.salesforce.com/forums/?id=906F0000000AaYEIA0) is the developerforce thread that gave me a clue that it was an issue and informed me to use a secondary lookup.
goravsethgoravseth
Interesting. That issue is from when fast elementd were in beta and is marked as resolved though there is one comment from 2015. Are you sure you are storing those.values in your sobject collection that is generated from your fast lookup? You have to specify each field to store in the fast lookup.
Gavin GuinaneGavin Guinane
Yeah, I think it's still an issue. I'm setting the values in the initial Fast Lookup but they aren't being picked up or set. If I log the contents of the recordset it just has ID's in the collection...no additional field values.....
goravsethgoravseth
Hmm.  Tested and the flow I built initially for this still is working fine, no inner lookup.  If you use a screen to display values for the fields after the fast lookup are they populated?  And same in the loop?   In my experience as long as you are storing those fields from the fast lookup, you can access them in the loop variable.
Megan Moody 33Megan Moody 33
@Gavin - Excellent video! I followed it step-by-step. The problem is that when I go to save the flow I get the following errors (i named everything very close to yours to make following along easier):

- assignment (Assignment): The section of the flow starting from "assignment" is never used. 
- then the same message for the fast lookup, the loop, and the record lookup. 

Have you ever seen these types of errors before? I fairly new to Visual Flows.I am doing the flow off of a custom object rather than account. But I can't imagine that makes a difference does it? 
goravsethgoravseth
Hmm. The flow I built initially still works fine. If you use a screen to display values for the fields after the fast lookup are they populated? And same in the loop?
osizeosize
I am experiencing this same issue as @gavin. Only the Id get displayed even though the additional fields are assigned. 
Andy Kallio 7Andy Kallio 7
Hi All. Really appreciate this feed. I have it pretty much worked out thanks to it, but have one problem. My display text shows the records more than once. My case is that I am putting throught the user through a loop by asking having them add a product to an opportunity, and then asking them if they want to add another, choosing yes will take them back through loop, and within the loop I have a collection that contains each product they select. I iterate through the collection using the loop element and build a text template  following the advice above. I put this product summary on the page where they are asked if they want add another product so that the user can keep track of what they have added...helpful when 4 or more line items are needed.The only problem is if I chose to select another product then first product shows up twice and if then if add another then the first product appears 3x and the second product appears 2x and so on. 

Any ideas on how to make the collection unique?
Andy Kallio 7Andy Kallio 7
Just figured out my problem. I have to set the Display Variable to null each time the user chooses to add a new product. 
Megan Moody 33Megan Moody 33
@Gavin - Thanks for your reply. I found what my issue was and am documenting here in case anyone makes the same mistake I did. I had my display screen set as my Start Element. The fast lookup should be the Start Element. 
Sandy GaliSandy Gali
What if we dont use a fast lookup and loop is the starting element in the loop. 
I am trying to implement something like this http://andyinthecloud.com/2015/12/12/visual-flow-with-list-view-and-related-list-buttons/
and if I use a formula variable it doesnot seem to work.
I get this error : The flow failed to access the value for <formula field> because it hasn't been set or assigned.
My formula field is referrring the parent and I raised a new question before I saw this.

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000D9qQIAS

All this seems so basic to me and it doesnt seem to be working from years!!!

Please let me know if anyone made it work before , not sure if I am doing something completely dumb.

 
goravsethgoravseth
Usong andys method, to reference a field on a parent record, you must update the visualforce page to include the lookup field to the parent. Cross object field references should work then. See this text Then create the following Visualforce page, changing the object name and list of fields accordingly. This will ensure selected records are passed to your Flow. Have you done this step? Sandy Gali replied to your question at 9:53 PM on 3/1/2016. Original question: I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field. If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3]. Is there any way to get the flow to produce something along the lines of: Name1, Value1 Name2, Value2, Name3, Value3, in a display text field? If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that. Thanks (Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J) Reply: What if we dont use a fast lookup and loop is the starting element in the loop. I am trying to implement something like this http://andyinthecloud.com/2015/12/12/visual-flow-with-list-view-and-related-list-buttons/ and if I use a formula variable it doesnot seem to work. I get this error : The flow failed to access the value for because it hasn't been set or assigned. My formula field is referrring the parent and I raised a new question before I saw this. https://developer.salesforce.com/forums/ForumsMain?id=906F0000000D9qQIAS All this seems so basic to me and it doesnt seem to be working from years!!! Please let me know if anyone made it work before , not sure if I am doing something completely dumb. Tip! To respond, either reply to this email or click this link: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Awtc The information in this e-mail (including attachments) is confidential and may be legally privileged. If you are not an intended recipient, please immediately inform the sender and delete this e-mail and any attachments. Ashoka does its part to protect our world: please consider the environment before printing this message.
Sandy GaliSandy Gali
Yes, I have inlcuded the reference field on the VF page

My code is :

<apex:page standardController="Opportunity" tabStyle="Opportunity" recordSetVar="AllOpportunities">
    <!-- Add below each field you reference in your Flow -->
    <apex:repeat value="{!AllOpportunities}" var="row" rendered="true">

        {!row.Sales_Engineer__r.name}
        <br/>
      
    </apex:repeat>
    <!-- Runs your Flow -->
    <flow:interview name="SelectList"
          finishLocation="{!$CurrentPage.parameters.retURL}">
        <apex:param name="Input" value="{!Selected}"/> 
    </flow:interview>    
</apex:page>


I used the same thing in my flow too but it doesnot work.
goravsethgoravseth
I think if you just include the sales_engineer__c field that should work. You can do cross object field references once you store the relationship field in the sobject variable/collection. See the help and training docs on cross object field references in flow for more details. Sandy Gali replied to your question at 2:58 PM on 3/2/2016. Original question: I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field. If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3]. Is there any way to get the flow to produce something along the lines of: Name1, Value1 Name2, Value2, Name3, Value3, in a display text field? If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that. Thanks (Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J) Reply: Yes, I have inlcuded the reference field on the VF page My code is : {!row.Sales_Engineer__r.name}
I used the same thing in my flow too but it doesnot work. Tip! To respond, either reply to this email or click this link: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Awtc The information in this e-mail (including attachments) is confidential and may be legally privileged. If you are not an intended recipient, please immediately inform the sender and delete this e-mail and any attachments. Ashoka does its part to protect our world: please consider the environment before printing this message.
Sandy GaliSandy Gali
Forgot to tell this, Sales_Engineer__c is  a custom lookup field on the user object and using Sales_Engineer__c only renders the ID field. Using Sales_Engineer__r.name errors out.
goravsethgoravseth
You need __c in your sobject collection. Then you can use a formula field in your flow to reference fields on the related object. However, if __c is blank it will throw an error if you try to evaluate __r. Read the docs here for the format you would use in the flow https://help.salesforce.com/HTViewHelpDoc?id=vpm_designer_crossobject_reference.htm&language=en_US First get your flow working on its own, populating the sobject collection from a lookup. Then once that is working, you can work on getting it to run from the list button. Sandy Gali replied to your question at 4:31 PM on 3/2/2016. Original question: I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field. If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3]. Is there any way to get the flow to produce something along the lines of: Name1, Value1 Name2, Value2, Name3, Value3, in a display text field? If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that. Thanks (Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J) Reply: Forgot to tell this, Sales_Engineer__c is a custom lookup field on the user object and using Sales_Engineer__c only renders the ID field. Using Sales_Engineer__r.name errors out. Tip! To respond, either reply to this email or click this link: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Awtc The information in this e-mail (including attachments) is confidential and may be legally privileged. If you are not an intended recipient, please immediately inform the sender and delete this e-mail and any attachments. Ashoka does its part to protect our world: please consider the environment before printing this message.
KDR75DEVKDR75DEV

Question...

The video was very helpful.  However, I'd like to have the ability to provide an input field for each row in the output screen.  For example, in your video, imagine having a "Tax ID" field that you want to collect for each Account that is presented in the output table.  Any ideas on how to pull that off with Flow? Thanks!

goravsethgoravseth
You need visualforce, flows can't give you N number of fields on a single page. W flow you could loop through a screen for each record, but no way to have N records per page. Kevin Rall replied to your question at 11:45 AM on 3/6/2016. Original question: I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field. If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3]. Is there any way to get the flow to produce something along the lines of: Name1, Value1 Name2, Value2, Name3, Value3, in a display text field? If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that. Thanks (Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J) Reply: Question... The video was very helpful. However, I'd like to have the ability to provide an input field for each row in the output screen. For example, in your video, imagine having a "Tax ID" field that you want to collect for each Account that is presented in the output table. Any ideas on how to pull that off with Flow? Thanks! Tip! To respond, either reply to this email or click this link: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Awtc The information in this e-mail (including attachments) is confidential and may be legally privileged. If you are not an intended recipient, please immediately inform the sender and delete this e-mail and any attachments. Ashoka does its part to protect our world: please consider the environment before printing this message.
Geert AdamsGeert Adams
great post, will be sure to try it out as I have a similar requirement for our project. thanks!!
t4runjaint4runjain
+ @SalesforceYoda

Your answer solved my issue, I was facing since last 2 weeks, but did not get a sloution from anybody, I ahd a requirement to pass a list of string to apex method from the flow, I was using a collection variable to passs, but it was not showing on source column to pass in apex method.

After reading your answer, we realized that, we doesnt need to create a colleciton variable, as a simple stiring variable can also handle a list functionalities. So I used the variable and added the ids by using add method nit equal, in the loop.

I delivered it to client, and I beleive it works great!

Thanks very much for your answer once again @SalesforceYoda
Leandro Valdes VieraLeandro Valdes Viera
Is there a way to get the size of a list before doing this?

Thanks!!
kermit.thefrogkermit.thefrog
@SalesforceYoda

Great stuff. Thank you so much for sharing this with us.
Justin Tauber 6Justin Tauber 6
"goravseth: Great - i forgot to mention that was a 'two way' arrow [😊] glad you figured it out."

Took me a while, but I eventually figured out that THE TWO WAY ARROW FROM LOOP TO ASSIGNMENT IS REALLY IMPORTANT!  
Just reiterating that fact for other newbies. ;-)
patricia.lemondpatricia.lemond
Followed Gavin Guinane's video carefully and it worked the first time.  Thank you so much!
athimathi sachithanandamathimathi sachithanandam
Hi all,
I used Andy's list view custom button Which leverage Visualpage and flow.Pretty much same as Andy's approach. My logic has fastupdate after looping through list. It works only for 20 records and then end without any error.  I am using same logic in two different flow ,one do fast update and other just sum amount and display in screen. Both ends after 20 records. Either complete list are not passed from visualpage or loop not working after 20 records. But I am not sure and how to debug it or correct it.. Please help anybody.. thanks in advance
athimathi sachithanandamathimathi sachithanandam
Hi all,
I used Andy's list view custom button Which leverage Visualpage and flow.Pretty much same as Andy's approach. My logic has fastupdate after looping through list. It works only for 20 records and then end without any error.  I am using same logic in two different flow ,one do fast update and other just sum amount and display in screen. Both ends after 20 records. Either complete list are not passed from visualpage or loop not working after 20 records. But I am not sure and how to debug it or correct it.. Please help anybody.. thanks in advance
goravsethgoravseth
finally wrote up a short blog post on this approach, as well as a better approach to entering line breaks, which works in flow emails as well as in flow screens.

http://goravseth.com/manipulating-text-in-flows
Ronak DattaniRonak Dattani
This post saved me pulling out the rest of what little hair I have left!! I am currently doing the Process Automation Specialist SuperBadge step 6, and just couldn't get it to work. As pointed out by @Gavin for some reason the Fast Lookup only collects the record IDs, not all the fields as specificed by the lookup, and the only way round it was to do what Gavin shows in his video! Took me forever to find a solution, thank you Gavin!!!
Pamela DujovnePamela Dujovne
Can anyone tell me where is the error in my flow? I am getting crazy of this challenge! I only get the id of one single product. I post the screenshots. Please help me!!!
User-added imageUser-added imageUser-added imageUser-added imageUser-added image
Pamela DujovnePamela Dujovne
User-added imageUser-added image
Eric_SchubertEric_Schubert
Pamela - From the Loop to the Screen, you have an arrow where it says 'Next Element'. I think you are missing another arrow from the Screen back to the Loop to go back and get the next record it found from the Fast Lookup. Draw another arrow from the Screen to the Loop, so you have a two sided arrow between the two elements. Save the Flow and re-run it and let me know how it goes. Hope this helps!
Pamela DujovnePamela Dujovne
thanks for your help. I thinks it helps. But i am getting only the id of the product and no the name. Do you know the reason? I show you the debug.
Pamela DujovnePamela Dujovne
User-added image
Pamela DujovnePamela Dujovne
What it means that the interation is = 0?
Eric_SchubertEric_Schubert
Pamela - I think you need to update the Text Template. Instead of {!loopvariableforproducts}, pull down the 'Select Resource' drop down menu and look for your loop variable called loopvariableforproducts and choose 'Name'. When you are done, it will look something like this:
{!loopvariableforproducts.Name}
Now the screen should show the Name, not the ID.
Hope this helps!
Pamela DujovnePamela Dujovne
Perfect! I got the name! 👏 But only for one of the products. 😩 How can i get the names of all the products that contain the "choice" that the user choose in the first screen? You can look at my screenshots that i already post.
Eric_SchubertEric_Schubert
Pamela - I think you need to add an Assignment element before the Screen element. Have the Loop go to the Assignment element (and from the Assignment back to the Loop element!) so you have arrows in both directions. Create a new text variable. For the Assignment, for the variable drop down menu, choose the new text variable you created. For the operator drop down menu, choose 'Add'. For the value drop down menu, choose the text template you have. Then you want to connect the Assignment element to the Screen element. Save the Flow and re-run it and let me know how it goes. Hope this helps!
Pamela DujovnePamela Dujovne
I can't connect the assignment element to the screen element because it is already connected back to the loop element. How do i suppose to connect it? How can i disconnect one element that i already connect?
Eric_SchubertEric_Schubert
Click on the arrow to highlight it and then click the delete button to delete it.
Pamela DujovnePamela Dujovne
Is asking me this, what should i choose? Also i can not redirect the assignment element back to the loop and also to the screen element. I have to choose only one. What can i do? 
User-added image
Pamela DujovnePamela Dujovne
Could you connect an element with 2 elements? How?
Pamela DujovnePamela Dujovne
This is how it looks. I couldn't go back to the loop element.
User-added image
Pamela DujovnePamela Dujovne
When i run the flow, It takes me back to the first screen element, to choose one of the 3 options...
Eric_SchubertEric_Schubert
Choose the first option 'for each value in the collection'. To confirm the elements and arrows:
You want an arrow from the Loop element to the Assignment element and from the Assignment element back to the Loop element. Then you want an arrow from the Loop element to the Screen element (the arrow will say end of loop).
Pamela DujovnePamela Dujovne
I did what you said, but don't show me anything...
User-added image

Maybe i have to enter something here?

User-added image

This is the result

User-added image
Eric_SchubertEric_Schubert
Almost there! You can see the 3 Product Names in the Debug Details.
I think you need to update your screen element so it displays the new text variable you created rather than what is likely there now which is {!productsnames}.  
Pamela DujovnePamela Dujovne
great! it works! But i see the products in the same line. How can i see them in different lines?
Pamela DujovnePamela Dujovne
User-added image
Eric_SchubertEric_Schubert
You should be able to use this post from (the awesome!) Gorav Seth who explains how to get line breaks when you need to display a list of records from an sObject Collection on a screen element: https://goravseth.com/manipulating-text-in-flows
If you run into trouble, post back. Good Luck!
Pamela DujovnePamela Dujovne
Thanks for all your help! Now i have a new error that i don't know how to solve it. I added the flow element to the opportunity lightning page, and this is what it shows me: We can't launch this flow because of a variable error. Send this error message to your admin. The value null is being provided for variable AssemblySystemproducts1 but isn't compatible with the variable's data type (String). Check the places where you implemented the flow ‒ such as through a Lightning page or a custom button ‒ and make sure that all provided values are compatible with the variables' data types.
Pamela DujovnePamela Dujovne
I tried to add the flow as a lightning component in the opportunity page, but i get an error. Can you tell me what this means and how to solve it? I will post my screenshots. We can't launch this flow because of a variable error. Send this error message to your admin. The value null is being provided for variable assignmenttextvariable3 but isn't compatible with the variable's data type (String). Check the places where you implemented the flow ‒ such as through a Lightning page or a custom button ‒ and make sure that all provided values are compatible with the variables' data types.
Pamela DujovnePamela Dujovne
User-added imageUser-added imageUser-added imageUser-added image
Pamela DujovnePamela Dujovne
User-added imageUser-added imageUser-added image
Eric_SchubertEric_Schubert
Pamela - If you are trying to add the Flow as a component on a Lightning Page, please see this thread: https://success.salesforce.com/answers?id=9063A000000id3jQAA
Pay special attention to the name of the variable in your Flow and the input/output type. Good Luck!
Pamela DujovnePamela Dujovne
Thanks for your help!. But in my case, it has to be input-output. Because i need the names of the products to be shown in the flow. I tried with input-output for all the variables, private for all the variables, input for all the variables, input, private, private, input, input, private and so on. And i still get the same error. I am getting crazy with this flow!! IF i need to lookup to records and show them in the screen flow, i think that should be input to take the names of the records and output to show the records. Am i thinking right? Maybe i show you the variables and you can tell me what you think...
Pamela DujovnePamela Dujovne
User-added imageUser-added imageUser-added imageUser-added imageUser-added image
Pamela DujovnePamela Dujovne
User-added imageUser-added image
User-added imageUser-added image
Pamela DujovnePamela Dujovne
Maybe i have to change the type of the loop variable, from sobject variable to text variable?
Eric_SchubertEric_Schubert
Hey Pamela!
Sorry for leaving you hanging on this one. Did you ever get your Flow working?
Pamela DujovnePamela Dujovne
Yes! I did a very simple flow that passed the requerements. Thanks a lot!
cruttley2cruttley2
Great thread. I had the same need, and was able to code my FLOW as directed in the first few posts, with line feeds. Thanks!
Nick Frates 2Nick Frates 2
+1 
Charles DeVriesCharles DeVries
Thank you!!! This helped so much.