You need to sign in to do that
Don't have an account?
goravseth
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)
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)
- 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
- 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.
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!
Thank you both this will become very useful!
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?
@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.
Let me know what you think. Thanks!
My bad should hvae looked at your assignment. you should assign the text template to the variable:
{!VARDisplayOpportunities} ADD {!TT_FastLookup}
Side question: I am guessing I can use the data captured in the text template in an email to someone?
Thanks again!
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?
- 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?
Any ideas on how to make the collection unique?
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.
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.
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.
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!
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
Thanks!!
Great stuff. Thank you so much for sharing this with us.
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. ;-)
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
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
http://goravseth.com/manipulating-text-in-flows
{!loopvariableforproducts.Name}
Now the screen should show the Name, not the ID.
Hope this helps!
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).
Maybe i have to enter something here?
This is the result
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}.
If you run into trouble, post back. Good Luck!
Pay special attention to the name of the variable in your Flow and the input/output type. Good Luck!
Sorry for leaving you hanging on this one. Did you ever get your Flow working?
1 - Record Collection
Create your record collection (get records element). Make sure to capture “All records.”
2 - Loop Through Collection
Create Loop element
3 - Create “Current Item” Text Template
Create a text template and put into it values from the “current item” variable that comes from your Loop element. You can even create dynamic links and use formatting in the template.
4 - Create Text Variable
This text variable will “collect” all the values added from the “current item” text template you just created.
5 - Assign Values
Use the following equation to add each occurrence of your text template into the variable: Variable: TextVariable - Operator: "Add" - Value: TextTemplate
6 - Loop through the assignment for each item, and then go to your display element after the last one.
7 - Create Display
Add your compilation text variable to a “display text” component…and voila! Now you can see the variable unloads all the record values it collected through the loop.