Skip to main content

Flow Loop Basics

Have you ever been stumped by those weird "Fast Lookup" things? Or do loops and collection variables have you puzzled? This post hopes to explain those concepts while covering some of the basics of using a loop in a flow.

I'm going to cover the basics of using a loop in a flow. To save you the time, here's a link to install the config I'll be using if you'd like to follow along: Basic Flow Loop Config


When you feel good about this, learn how to launch the flow from Process Builder or a Visualforce page in my next post: Launch a Flow From Process Builder or Visualforce.

Highlights from the video

Variable Naming Convention

Make one that works for you, but this is what I use.
Variable: v_{name}
Collection Variable: vColl_{name}
SObject Variable: so_{name}
SObject Collection Variable: soColl_{name}
*{name} is the name of the variable

Variable Input/Output Type

Private: Only accessible within the flow. The value cannot be set by something outside of it (Process Builder, another Flow, a Visualforce Page, etc.)
Input Only: Private + its value can be set by something outside of it. Its value cannot be passed to anything else (ie. You *cannot* pass this variable to another Flow and use it there)
Output Only: Private + its value can be passed to something else (ie. You *can* pass this variable to another Flow and use it there)
Input/Output: Private + Input + Output. I use this just about every time

Comments

  1. HI Brett. Nice Blog thanks. I'm new to flow and want to create some forms. For example, when a person is attending 4 weeks of on-the-job-training, the trainer needs to review his/her performance every day to 5 sets of criteria. Each criteria could hace a score of 1-5 via radio buttons and, at the end of the week and at the end of the course, simply aggregate the scores to give an overall performance profile. So, I was thinking of creating a custom object, Performance Record and via flow, update the record as and when. Maybe even use the new Guided Actions feature to help collecting this. Is Process Builder & Flow the way to go? How can I get help on this? I also want to become more proficient on the entire flow and SOQL thing so, other than Trailhead what help can I get?

    ReplyDelete
    Replies
    1. From the info you gave I would suggest going the custom object route you described but make sure it is a child in a master-detail relationship to the parent object. With this relationship you can use a rollup summary field to aggregate the scores.

      Trailhead and other blogs are great resources to use in learning flow. I have a few other posts on it but they are pretty specific. I'd recommend looking for resources that cover the topic more generally and applying those to what you're working on

      Delete

Post a Comment

Popular posts from this blog

Salesforce Lighting Migration: Plan for Success

In April 2018, I led the Salesforce Lightning Migration at Postmates . This is how I would do it over again if I could. Define Goals The goals of a Lightning Migration are: Enable Lightning Experience Configure Lightning Experience Document all Salesforce processes Create training and support materials Lightning Experience is adopted Easy enough right? Let's go though the plan to see how we accomplish each one. Enable Lightning Experience Just turn it on right? Well, kinda. Although it may be controversial, I recommend turning it on and hiding the option from all users. This can be done by removing the Lightning Experience User permission from your custom profiles.  And yes, turn it on in production .  Why? You're going to turn it on anyway. Salesforce has declared this as the path forward, so you either turn it on now or wait until they flip the switch for you. Plus, turning this on ahead of time will make deploying from a sandbox much  e

Joins in SOQL

If you are familiar with SQL, the biggest gotcha when writing SOQL is how joins are done. You'll see the term  Sub-Query  used instead of  JOIN  because of how queries are done on the Salesforce platform. You can still do joins; it's just done a little differently than you're used to. Sub-Query (Outer Join) In SQL, a join is when rows are selected from multiple tables and joined together on common columns. Thinking about your tables like a Venn Diagram is a great analogy for this. Let's say you want to query all Accounts and also include their related Opportunities. This is an example of an Outer Join because it selects all Accounts and will include their related Opportunities via the sub-query. If an Account does not have an Opportunity, it will still be returned here. An Outer Join is similar to selecting one whole circle in a Venn Diagram, including the area that overlaps with the other circle. Sub-Query (Inner Join) An inner join can seem a little m

Modify Salesforce Data from the Command Line

When doing Salesforce data loads, how often are you putting the same value in an entire column? I find this happening when I need to: Move all accounts from one user to another Assign a set of leads to a specific user Set a field to a specific value Let's use the example from my other post: Salesforce Data Loads from the Command Line - Move all accounts owned by one user to another user. Magic Let's break down each piece of this: soql This is an alias I set for sfdx force:data:soql:query --query . It saves me from having to type this out each time and let's me query from the command line by just typing soql  and my query. This is a popular StackExchange post  that talks about how to set an alias. cat This command outputs the contents of a file. It is common to use this command with other commands by piping the output into another command. In our example, we are piping the output into the cut command. This post gives more examples of how to use t