Creating Salesforce Flows
Hello and welcome. The objective of this article is to provide those new to Salesforce Flows with instruction on how to build a record-triggered flow that automatically updates a record (the Account) once a related record (the Opportunity) has been updated. As well, the article hopes to share insight on why certain steps are taken, so that the concepts may become easier to understand and transferable when creating other flows.
Overview of Flow
The record-triggered flow that we will create is going to be triggered by any Opportunities that are updated to ‘Closed.’ If the Opportunity is ‘Closed Won,’ we will have the flow update the related Account’s Type to ‘Customer – Direct,’ if the Opportunity is Closed Lost we will have the flow check the related Account for Cases that have a Status of ‘New,’ ‘Working,’ or ‘Escalated.’ If any cases are found to be in one of the aforementioned statuses, we will still update the Account’s Type to ‘Customer – Direct.’ If the Opportunity is ‘Closed Lost’ and no Cases are found in the aforementioned statuses, we will have the flow update the related Account’s Type to ‘Other.’
NOTE: In an effort to separate the step-by-step process of building the flow from my thoughts/opinions/experiences, I will be using italics for my thoughts/opinions/experiences.
Building the Flow
- Preparation
- Setup
- Type ‘Flows’ into the ‘Quick Find’ Search Bar
- Search ‘Flows’
- Select ‘Flows’ (Underneath Process Automation)
- Select ‘New Flow’ Button
- Select ‘Record-Triggered Flow’
- Select the dropdown that shows ‘Auto-Layout’
- Change it to ‘Freeform’
- Build Start
- On ‘Configure Start’ Screen
- Beneath ‘Select Object’ and ‘Object,’
- Select from the picklist ‘Opportunity’
- Beneath ‘Configure Trigger’ and ‘Trigger the Flow When,’
- Select ‘A record is updated’
- Beneath ‘Set Entry Conditions’ and ‘Condition Requirements,’
- Select ‘All Conditions Are Met (AND)
- Field: Select ‘IsClosed’
- Operator: Leave as ‘Equals’
- Value: Select ‘$GlobalConstant.True’
- Select ‘All Conditions Are Met (AND)
- Beneath ‘Select Object’ and ‘Object,’
- On ‘Configure Start’ Screen
This field, once selected, will read as ‘True.’
-
-
- Select the ‘Done’ Button.
-
The field, operator, and value along with our chosen object – opportunity – establishes the basis of our flow and when the flow will activate. So, in our case, at any point that an opportunity is updated and closed, the flow will activate, and check for additional criteria established in our elements. More on this in the following steps.
- Save Flow
- Select ‘Save’ Button
Top right corner.
-
- Flow Label: Type ‘Update Account Type Field When Opportunity is Closed’
- Click the ‘Tab’ Button on your keyboard or click into a different field to auto-populate the Flow API Name.
- Description: Type ‘Update Account Type Field When Opportunity is Closed. Closed Won = Customer – Direct. Closed Lost with Case Status of ‘New,’ ‘Working,’ or ‘Escalated’ = Customer – Direct. Closed Lost with Case Status of ‘Closed’ or No Cases = Other.’
- Select the ‘Save’ Button.
You should receive a warning, “The flow can’t run because nothing is connected to the Start element.” Close the window as we have not added elements to our flow yet, so it would not be able to do anything in its current state.
To the left of your screen, you should see the ‘Toolbox.’ Below the Toolbox are two tabs: ‘Elements’ and ‘Manager.’ Elements are important because they perform the work of the flow. We will be using the ‘Assignment,’ ‘Decision,’ ‘Update Records,’ and ‘Get Records’ elements during this exercise.
Though we will work with each element in the following steps, consider the general idea behind the elements. After we’ve set our criteria for the flow – check the closed opportunity to see if conditions are met to update the related account – we will use the elements to perform the needed checks. The elements will then be chained together for those checks to be completed. The simplest example being, decide what stage the closed opportunity is in (Decision Element), if in a closed-won stage, then update the related account’s type to Customer – Direct (Update Records element). If it were in a closed lost stage, then we would need to check the cases on the account (Get Records Element). After we get the records, we will have to assign the records (Assignment Element) so that a new decision (Decision Element) can be made based on the records (cases) we got.
ELEMENT #1: Decision
-
- Select and Drag a Decision Element from the Toolbox to the flow’s canvas. A window will open.
- Label: Type ‘Check the Opportunity Stage for Closed Won or Closed Lost’
- Select and Drag a Decision Element from the Toolbox to the flow’s canvas. A window will open.
- Tab or Click into a different field to auto-populate the API Name
- Beneath ‘Outcomes’ and ‘Outcome Details,’
- Label: Type ‘ Closed Won’
- Tab or Click into a different field to auto-populate the Outcome API Name.
- The ‘New Outcome’ below ‘Outcome Order’ should change to ‘Closed Won.’ This signifies the first of two decision paths for this decision element.
- Leave ‘Condition Requirements to Execute Outcome’ as ‘All Conditions Are Met (AND)’
- Resource Field: Select ‘$Record Opportunity’ > ‘StageName Stage’
- This will appear as $Record > Stage once selected.
- Resource Field: Select ‘$Record Opportunity’ > ‘StageName Stage’
- Beneath ‘Outcomes’ and ‘Outcome Details,’
Also, note that I’m listing the fields exactly as you will see them. Navigating these lists when learning flows can feel overwhelming, so I want to lessen room for confusion.
-
-
-
- Operator Field: Leave as ‘Equals’
- Value Field: Select ‘Closed Won Text’
-
-
This will appear as ‘Closed Won’
-
-
- Below Outcome Order, Select ‘Default Outcome’
- Below ‘Outcome Details’
- Label Field: Type ‘ Closed Lost’
- Below ‘Outcome Details’
- Below Outcome Order, Select ‘Default Outcome’
-
Notice that there isn’t a Conditions Requirement to Execute section. That is because if the opportunity does not meet the set closed won criteria then it will default to this path and check for additional elements for the next steps to take. So, this decision element essentially focuses on closed won or closed lost.
-
-
- Select ‘Done’ Button
-
- Connect your Start to your Decision Element. By selecting the white circle/dot and dragging it to the white circle/dot on the Decision Element.
For future elements you can connect them in whatever manner you like (more or less) and you may accidentally connect wrong elements due to proximity or the like. If that were to happen, you can select the connecting path. It will highlight in blue. At this time, you may press ‘delete’ on your keyboard to remove the pathway.
Also, in the upper left corner of your screen is the undo arrow and the redo arrow. These can come in handy.
- Save your flow by clicking the ‘Save’ button.
ELEMENT #2: Update Records
-
- Drag and drop the Update Records Element from the Toolbox onto your Canvas. I recommend placing it to the left of your previously created Decision Element.
- This can be rearranged later if the ‘New Update Records’ window has already opened.
- A ‘New Update Records’ window should automatically open.
- Label: Type ‘Update Account Type to Customer – Direct’
- Tab or Click into a different field to auto-populate the API Name.
- Description: Type ‘Update Account Type to Customer – Direct’
- Drag and drop the Update Records Element from the Toolbox onto your Canvas. I recommend placing it to the left of your previously created Decision Element.
Remember, for future assignments, labels and descriptions are decided by best practices for your team and wording that makes the most sense for the typical user. So, feel free to use shorthand if it’s discernible or to write lots in your description if you want to be helpful to those that come after you or if you know you won’t remember what you were working on months later… certainly not something that has happened to me. Nope.
-
-
- Beneath ‘How to Find Records to Update and Set Their Values,
- Select ‘Specify conditions to identify records, and set fields individually’
-
The window will change to show ‘Update Records of This Object Type’ and below it will be a new field.
-
-
-
- Object: Select, ‘Account Account’
-
-
The window will change to show additional fields.
-
-
- Beneath ‘Filter Account Records’
- Condition Requirements to Update Records: Leave as, ‘All Condition Are Met (AND)’
- Field: Select ‘Id Account ID’
- Operator: Leave as, ‘Equals’
- Value: Select ‘$Record Opportunity’ > ‘Account Account ID’ > ‘Id Account ID’
- Beneath ‘Set Field Values for the Account Records’
- Field: Select ‘Type Account Type’
- Value: Select ‘Customer Direct Text’
- Select ‘Done’ Button
- Connect your ‘Decision’ Element to your ‘Update Records’ Element.
- A window will pop up titled ‘Select outcome for decision connector’
- Outcome: Select ‘Closed Won’
- Select ‘Done’ Button.
- A window will pop up titled ‘Select outcome for decision connector’
- Beneath ‘Filter Account Records’
-
A pathway should appear between your two elements. Notice that the pathway lists the expected results of the path, ‘Closed Won.’
-
-
- Save your Flow.
-
ELEMENT #3: Get Records
-
- Drag and drop the Get Records Element from the Toolbox onto your Canvas.
- I recommend placing it to the right of your previously created Decision Element. This can be rearranged later if the ‘New Get Records’ window has already opened.
- A ‘New Get Records’ window should automatically open.
- Label: Type ‘Get Open Case Records For Opportunity’s Account’
- Tab or Click into a different field to auto-populate the API Name.
- Description: Type ‘Search for and store any open cases related to the opportunities account. These cases should have a status of new, working, or escalated.’
- Drag and drop the Get Records Element from the Toolbox onto your Canvas.
You’ve probably already been copying and pasting, which is fine – work smarter not harder, right? But, do consider reading through each piece of information to help grasp the process whether typing or copying and pasting. And don’t forget to make those descriptions useful for later review.
-
-
- Beneath ‘Get Records of This Object’
- Object: Select, ‘Case Case’
- Beneath ‘Get Records of This Object’
-
The window will change to show additional fields.
-
-
- Beneath ‘Filter Case Records’
- Condition Requirements: Select, ‘Custom Condition Logic Is Met’
- Use the ‘+ Add Condition Button’ to add three (3) additional lines.
- 1
- Field: Select ‘AccountId Account ID’
- Operator: Leave as, ‘Equals’
- Value: Select ‘$Record Opportunity’ > ‘Account Account ID’ > ‘Id Account ID’
- Beneath ‘Filter Case Records’
-
-
-
-
-
- 2
-
-
-
-
-
-
-
- Field: Select ‘Status Status’
- Operator: Leave as, ‘Equals’
- Value: Select ‘New Text’
-
-
-
-
-
-
-
- 3
-
-
-
-
-
-
-
- Field: Select ‘Status Status’
- Operator: Leave as, ‘Equals’
- Value: Select ‘Working Text’
-
-
-
-
-
-
-
- 4
-
-
-
-
-
-
-
- Field: Select ‘Status Status’
- Operator: Leave as, ‘Equals’
- Value: Select ‘Escalated Text’
- Below ‘Custom Condition Logic Is Met,’ is ‘*Condition Logic’
- Type, ‘1 AND (2 OR 3 OR 4)’
-
- Beneath ‘Sort Case Records’
- Sort Order: Leave As ‘Not Sorted’
- How Many Records to Store: Select, ‘All Records’
- How to Store Record Data: Select, ‘Automatically store all fields’
- Select ‘Done’ Button
- Connect your ‘Decision’ Element to your ‘Get Records’ Element.
-
-
A window will NOT pop up as it did last time, because there is only one result available for the path, ‘Closed Lost,’ so it is automatically filled in for us.
-
-
- Save your Flow.
-
ELEMENT #4: Assignment
-
- Drag and drop the Assignment Element from the Toolbox onto your Canvas.
- I recommend placing it to the right of your previously created Get Records Element. This can be rearranged later if the ‘New Assignment’ window has already opened.
- A ‘New Assignment’ window should automatically open.
- Label: Type ‘Assign Open Cases’
- Tab or Click into a different field to auto-populate the API Name.
- Description: Type ‘Assign Open Cases’
- Beneath ‘Set Variable Values’
- Variable: Click into field, then Select, ‘New Resource’
- Drag and drop the Assignment Element from the Toolbox onto your Canvas.
The ‘New Resource’ window automatically opens.
-
-
- On the New Resource Window
- Resource Type: Select, ‘Variable’
- On the New Resource Window
-
From the list of resources, our options were ‘Variable,’ ‘Constant,’ ‘Formula,’ ‘Text Template,’ and ‘Stage.’
Variable was something I hadn’t worked with before flows, so I found them to be one of the more difficult parts of learning flows. At one point, I was creating variables that were working within the flow without understanding why which led to a lot of backtracking and second guessing. So, know that Variables are true to their standard day-to-day definition within flows. By that, I mean they are the opposite of their counterparts, Constants. If we were to pick a Constant as our Resource Type we would be setting a permanent value (text, number, etc.) for the flow to compare its results to. In our case, we will Assign our Variable to hold the number of records (cases) found by our Get Records Element. This will become useful with our future Decision Element that decides whether our account has cases or not – an important criteria for deciding the path of the flow. The Variable becomes necessary as our flow will be checking cases across various accounts with differing amounts of cases, especially as time goes on.
-
-
-
- API Name: Type, ‘AmountOfOpenCases’
-
-
We aren’t using spaces for this title because it’s an API Name, which does not allow spaces.
-
-
-
- Data Type: Select, ‘Number’
-
-
We are selecting number because we want the variable to count the amount of cases found by the Get Records Element, so that we can have our upcoming Decision Element move forward on the basis of whether we have at least one case record in an ‘Open’ status.
-
-
-
- Decimal Places: Delete any prepopulated data. Then, type ‘0’
- Default Value: Leave blank.
- Beneath, Availability Outside the Flow:
- Available for input: Leave Unchecked
- Available for output: Leave Unchecked
-
-
A quick note to keep in mind that I picked up from Trailhead. If you are ever unsure about whether these fields should be checked or unchecked, then check ‘available for input,’ but do NOT check ‘available for output.’ In our case, we don’t need this data outside of the flow, so both will be unchecked.
-
-
-
- Select ‘Done’ Button
-
-
You should return to the Assignment Element and the ‘Variable’ field should be populated with our newly created Variable titled ‘AmountOfOpenCases’ and appearing as a blue hyperlink.
-
-
- Operator: Select ‘Equals Count’
-
Equals Count because we are counting the records, so we want to focus on the amount rather than text or the like.
-
-
- Value: Select ‘Cases from Get_Open_Case_Records_For_Opportunity_s_Account Case’
-
This is the information from our Get Records Element and by placing it with the Variable we created the Variable will hold the record count for use in our upcoming Decision Element.
-
-
- Select ‘Done’ Button
- Connect your ‘Get Records’ Element to your ‘Assignment’ Element.
-
A window will NOT pop up, because there isn’t a variety of paths as is the case with a Decision Element.
-
-
- Save your Flow.
-
ELEMENT #5: Decision
-
- Select and Drag a Decision Element from the Toolbox to the flow’s canvas. A window will open.
- Label: Type ‘Open Cases Decision’
- Tab or Click into a different field to auto-populate the API Name
- Beneath ‘Outcomes’ and ‘Outcome Details,’
- Label: Type ‘Open Cases Found’
- Tab or Click into a different field to auto-populate the Outcome API Name.
- Label: Type ‘Open Cases Found’
- Leave ‘Condition Requirements to Execute Outcome’ as ‘All Conditions Are Met (AND)’
- Resource Field: Select ‘Amount of Open Cases Number’
- Operator Field: Select ‘Greater Than or Equal’
- Value Field: Type ‘1’
- Below Outcome Order, Select ‘Default Outcome’
- Below ‘Outcome Details’
- Label Field: Type ‘No Open Cases Found’
- Below ‘Outcome Details’
- Select ‘Done’ Button
- Label: Type ‘Open Cases Decision’
- Select and Drag a Decision Element from the Toolbox to the flow’s canvas. A window will open.
- Connect your Assignment Element to your Decision Element.
- Connect your Decision Element for Open Cases to your Update Records Element.
- A window will pop up titled ‘Select outcome for decision connector’
- Outcome: Select ‘Open Cases Found’
- A window will pop up titled ‘Select outcome for decision connector’
Remember, a Closed Won Opportunity or an Account with active Cases have the same Account Type, so our flow has two decisions to make that may lead us to the same results.
-
-
- Select ‘Done’ Button.
- Save your Flow.
-
ELEMENT #6: Update Records
-
- Drag and drop the Update Records Element from the Toolbox onto your Canvas.
- I recommend placing it below and to the left of your previously created Decision Element. This can be rearranged later if the ‘New Update Records’ window has already opened.
- A ‘New Update Records’ window should automatically open.
- Label: Type ‘Update Account Type to Other’
- API Name: Tab or Click into a different field to auto-populate the API Name.
- Description: Type ‘Update Account Type to Other’
- Beneath ‘How to Find Records to Update and Set Their Values,’ Select ‘Specify conditions to identify records, and set fields individually’
- Drag and drop the Update Records Element from the Toolbox onto your Canvas.
The window will change to show ‘Update Records of This Object Type’ and below it will be a new field.
-
-
-
-
- Object: Select, ‘Account Account’
-
-
-
The window will change to show additional fields.
-
-
- Beneath ‘Filter Account Records’
- Condition Requirements to Update Records: Leave as, ‘All Condition Are Met (AND)’
- Field: Select ‘Id Account ID’
- Operator: Leave as, ‘Equals’
- Value: Select ‘$Record Opportunity’ > ‘Account Account ID’ > ‘Id Account ID’
- Beneath ‘Set Field Values for the Account Records’
- Field: Select ‘Type Account Type’
- Value: Select ‘Other Text’
- Select ‘Done’ Button
- Beneath ‘Filter Account Records’
- Connect your previous ‘Decision’ Element to your new ‘Update Records’ Element.
- Save your Flow.
- Activate your Flow.
- Test your Flow.
-
Remember your opportunity should be created and saved, then updated for the flow to trigger. A Closed Won Opportunity will set the Account’s Type to Customer – Direct; A Closed Lost Opportunity with a Case in the New, Working, or Escalated Status will also set the Account’s Type to Customer – Direct; while a Closed Lost Opportunity on an Account with no Cases or Closed Cases will change the Account’s Type to Other.
Closing Remarks
So, what did we just do? We created a Flow. We learned about elements to include Decision, Update Records, Get Records, and Assignment. We learned about Variables. We learned a few tips and best practices, but most importantly we’ve improved our personal toolbox. Maybe this was a refresher for you, maybe it was your first attempt at a flow, maybe you’re just window shopping for the future. Either way, you’re taking a step in the right direction and I hope I helped with those steps. Of course, you can take this example and modify it for your assignment. Maybe you want to update whether an account is hot, warm, or cold. Maybe you want to update an account with a custom object that specifies a cooldown period after a Closed Lost opportunity. We didn’t cover e-mails, but if you can do this you wouldn’t be unable to send an automated e-mail to your team highlighting a colleague’s success after a Closed Won opportunity! Have fun with it.
I hope this article was helpful for you to learn how to create your first record-triggered flow with no experience. Feel free to reach out if you have any questions.
Kurt Forbes
Salesforce App Builder
Kurt, one of our Salesforce Certified Administrators, takes delight in providing solutions through the ever-growing Salesforce platform and is excited to continue exploring the many creative avenues available with out-of-the-box functionality. His curiosity, passion for quality and sound solutions pushes him to continue growing with the Salesforce ecosystem.
About Roycon
We’re an Austin-based Salesforce Consulting Partner, with a passion and belief that the Salesforce platform’s capabilities can help businesses run more efficiently and effectively. Whether you are just getting started with Salesforce or looking to realize its full potential, Roycon specializes in Salesforce Implementations, Salesforce Ongoing Support, and Salesforce Integrations, and Development. We’re the certified partner to guide the way to increase Salesforce Adoption, make strategic decisions, and build your Salesforce Roadmap for success.