Search

Salesforce Flows with Example

  • Share this:
post-title

We will be able to : 

  • 1. Create Flows by Yourself

  • 2. Understand why the flow was introduced in the world when we already got Workflows, Process Builder, Triggers

What is a Flow?

 A Flow is a tool to automate the business process.

Why are Flows introduced?     

We got Apex, Triggers, Lightning Components , Lightning Web Components with these things we can perform any implementation. There is a topic which is we need to know how to code.

Let's say I don't know how to do code but still want to do some implementation. Here Salesforce comes up with some features, out of which the first is the Workflow. We don't know the code, but we can perform actions. However, there is a limitation of four actions, but we can do more if we add Process builder to the Salesforce. That's where we can perform 11 actions more than workflows do. But process builder is also limited. For example, we can not delete a set of records; we can not do a custom roll-up summary action, not clone a record. So these things the process builder can not handle, so to do that we can do  with the help of Apex trigger, Lightning and Lightning Web Components until we got a new one which is “Flow”. 

Flows is a powerful tool because flows can build UI Screens; no other standard tools can do it. This makes it easy to add registration forms. We can make approval rules. It can also perform complex actions like deleting records, cloning records, and performing custom roll-up summary actions.

There are two types of flow:

   1. Screen Flow 

   2. Auto Launched Flow 

How do we need to select flow type?

Whenever a customer screen has to be implemented, we will first go for Screen Flow.

E.g. Create registration form, Create a Feedback form, Approval Steps

Scenario 1: Display “Hello World” Text on home page using screen flow. 

We will print the message on the screen at the Assistance Box

In the New Hello World Flow flow, open the screen.

  1. 1. From Setup, enter Flows in the Quick Find box, and select Flows.

  2. 2. Click on New flow.

  3. 3. From the Flow type select Screen Flow 

  4. 4. Click on Create

  5. 5. We need to drag and drop screen option

  1. 6. Uncheck Header and Footer from Configure Header Footer

  2. 7. Set Label Name : Message Screen

  3. 8. Set API Name: Message_Screen(Default)

  4. 9. From the Display select “Display Text” drag and drop on the box

  1. 10. In the message box Type “Hello World”

  2. 11. Font size : 20

  3. 12. Font type: Bold

  4. 13. API Name: displayText

  5. 14. Click on Done

  6. 15. Connect the Message Screen with Start

  7. 16. Click on Done

  8. 17. Connect the Message Screen with Start

  1. 18. Click on Save

  2. 19. Flow Label: Hello World Flow

  3. 20. Flow API Name: Hello_World_Flow

  4. 21. Click on Save

  5. 22. Review and Issues : Close

  6. 23. Click on Activate

  7. 24. Click on Back

  8. 25. Display the message Click on Home page 

  9. 26. Click on Setup and select Edit Page

  10. 27. Drag and Drop a Flow at Assistant Box

  11. 28. Select Hello World Flow at Flow

  12. 29. Click on Save

  13. 30. Click on Activate

  14. 31. Select Assign as Org Default 

  15. 32. Click on Save

  16. 33. Click on Home Page

  17. 34. Click on Save 

  18. 35. Go back and click on Home

 

2. Auto Launched Flow:  Auto Launched Flow launches when invoked by Apex, Process Builder or even REST API.

  • 1. Schedule Trigger Flow: This flow launches when record is created , deleted or updated

  • 2. Record Trigger Flow:This flow launches when record is created , deleted or updated

  • 3. Platform Event Flow:This flow launches when record is created , deleted or updated

  • 4. Auto launched Flow: Launches when invoked by Apex, Process Builder or even REST API

Scenario 2 :Create a Contact associated with an Account using the Autolaunch flow.

In the New Contact Account Autolaunch flow, open the screen.

  1. 1. From Setup, enter Flows in the Quick Find box, and select Flows.

  2. 2. Click on New flow.

  3. 3. From the Flow type select AutoLaunch Flow and Click Next 

  4. 4. Click Manager-> New Resource

  5. 5. Resource Type: Variable

  6. 6. DataType: Text

  7. 7. Available for Input: Checked

  8. 8. Click Done

Creating a Contact that is associated with Account record.

  1. 1. Click on Create Records

  2. 2. Set Label: “Create Contact” API Name: “Create_Contact”

  3. 3. How to set Record Fields: Select - Use Separate resource, and literal Values

  4. 4. Object: Contact

  5. 5. Set Fields for the Contact

  6. 6. Field : Last Name   Value: Test Last Name

  7. 7. Field : First Name   Value: Test First Name

  8. 8. Field : AccountId   Value: {!accountId}

  9. 9. Done

  10. 10. Link with Start

  1. 11. Save

  2. 12. Flow Label : Create Contact With Process Builder

  3. 13. Flow API Name: Create_Contact_With_Process_Builder

  4. 14. Done

  5. 15. Click on Activate 

  6. 16. Quick Find Process Builder

  7. 17. Click on New

  8. 18. ProcessName : Account Processing for Flow

  9. 19. API Name: Account_Processing_for_Flow

  10. 20. The Process Starts When : A record changes

  11. 21. Click on Save

  12. 22. Add Object: Object -> Account

  13. 23. Start the Process: Select “Only when a record is created”

  14. 24. Click on Save

  15. 25. Click on Add Criteria

  16. 26. Criteria Name: Always Run Account

  17. 27. Select  : No criteria—just execute the actions!

  18. 28. Click  on Save

  19. 29. Immediate Action Click on Add Action 

  20. 30. Select Action Type : Flows

  21. 31. Action Name : “Calling Flow”

  22. 32. Flow : “Create Contact With Process Builder”

  23. 33. Click Add Row 

  24. 34. Flow Variable : accountId Type: Field Reference Value: [Account].Id

  25. 35. Click on Save

  26. 36. Click on Activate

  27. 37. Click Confirm

Now here we can create a new Account automatically associated with contact.

Create an Account:

  1. 1. Click on Account

  2. 2. Click New 

  3. 3. Account Name: “Test Account for Flow”

  4. 4. Click on Save

Now we will see that contact is automatically created with the FirstName and LastName

Sushma Morey

Sushma Morey

My name is Sushma Morey. I am a Quality Application Engineer at mindZcloud Technologies. I love to learn new things and would like to share the knowledge.