Get started with Flows in Salesforce!

Ganesh Tenkale
Cloudwerx
Published in
10 min readSep 27, 2022

Flow is a very powerful business automation application that can collect, create, update, edit, and delete Salesforce Data. It will execute logic and guide users through screens for collecting and updating data as per business requirements.

Salesforce flows help you in simplifying complex business processes. Otherwise, it can make a mess. It can be used to perform various tasks like, sending an email, posting a chatter, sending custom notifications & etc.

Flow can be trigger for record insert, update and record delete and it can be run for both after and before events.

Following are the types of flow :

  1. Screen Flow (Covered in the blog)

2. Record Triggered Flow (Covered in the blog)

3. Schedule-Triggered Flows (Covered in the blog)

4. Auto Launch Flows

5. Platform Event Triggered Flow

Fig. 1: Hierarchy of Flow

Let us create a flow As you click on “Quick Find box” search for “Flows” and click on “New Flow” !

Fig. 2: Creating a New Flow

Select the flow as per your requirement :

Different Types of Flows:

  1. Screen Flow: Screen flows are the flows where users can interact, and they can either enter some inputs or select records in the available UI.
  2. Record Triggered Flow: It begins when a record is created or updated. Its functionality is similar to Process builder.
  3. Scheduled Triggered Flow: It runs automatically on a recurring schedule. It is helpful for jobs performed frequently or on a schedule (once, daily, weekly).
  4. Auto launch Flow: These can be called Apex, Process Builder, or another Flow. They can perform actions automatically behind the scenes.
  5. Platform event-triggered Flows: These are called when a platform event is received.

As you clicked on “New Flow” you can choose the flow type as shown below.

Fig. 3: Flow Types

As you select the flow & Free-Form is enabled then you can see on the left-hand side under the Element Tab there are Interaction, Logic & Data Elements are present.

Fig. 4: Element Tab View (Free Form is enabled)

Interaction Elements :

  1. Screen: Screen element / User interface for the flow. The screen can be used to display information or can be used to collect data from the user. This element is available only in Screen Flows.
  2. Actions: Actions are external actions that further extend the functionality of the flow. Some examples of actions — Apex, Send emails, etc.
  3. Subflow: A flow can initiate another flow.

Logic Elements :

  1. Decisions: Decisions split the flow depending on the data that’s being sent through the decision element.
  2. Assignments: Assignments give a value to a variable.
  3. Loops: Loops handle multiple variables at once using collections.

Data elements :

Data elements allow the flows to fetch, create, update or delete records in the database. The elements include Get Record, Create Record, Update Record, and Delete Record. Get Record is used to fetch record/s from the database. Create Record, Update Record, and Delete Record are used to activate the data in the database.

Connectors

Connectors decide the available paths that a flow can take at run time. Various elements in the flow are connected using the connectors available. Some types of connectors are Unlabeled, Decision Outcome, Fault, Pause, For each, etc.

1. Screen Flow:

From the new flow window, we will select screen flow, In screen flow we will be displaying Customize Welcome Message to the user, so click on screen element from add element section. When Auto-Layout is enabled you will see the view below.

Fig. 5: Element Tab View (Auto-Layout Enabled)

As you can see edit screen window is opened we have to click on Display Text.

Fig. 6: Screen Element

Below screen is the “Display Text” window here you can enter any message as you can see: Welcome {!$User.FirstName}Have a great day ahead.

from Insert a resource, we have to add $user & FirstName as shown in below image.

You can do formatting of messages like font size, color, style, bold, Italic, alignment setting, etc.

Fig. 7: Display Text View

Click on Done -> Save -> Debug -> Run. then you will see the user name with a welcome message like below fig.

You can add this flow on console page by clicking on setup (gear icon) -> edit page -> search for flow (drag & drop) -> Enter flow name (i.e Welcome Message) -> click on Save.

Fig.8: Screen Flow Result

2. Record Triggered Flow :

From the new flow window, we will select Record Triggered Flow, when a record is created or updated according to flow functionality it will work

We have to select an Object on which we are creating the flow & select Trigger the flow When: “A record is created or updated

Fig. 9: Configure Start Window

Click on Scheduled Paths to configure it according to offset number and offset options.

Fig. 10: Add Schedule Paths

Have to select Time source so depending on that field we will be selecting Offset Number & Offset Option. Offset Options contain menu such as Days After, Days Before, Hours After, Hours Before, Minutes After, Minutes Before. here We have selected Offset Number as 180 & Offset Options as Days Before so will receive email 180 days before the expiry date.

Fig. 11: Configure Scheduled Paths

Next, we will drag the decision from the logic section & add all the conditions which are required.

Fig. 12: Decision Box

We will then connect this through connectors by simply drag and drop the start point on decision point then we have to select the schedule path for that decision box. here in this, we will be selecting “The 6 months Prior Business Record Reminder” and Done.

Fig. 13: Connect Scheduled Path

For email, drag & drop Action element then filter by -> type -> email alert ->search the email template -> Done

Fig. 14: Email Action

Let’s set the input value as Record.Id then click on done.

Fig. 15: Set Input Values for Email Action

Next, we will connect the decision box with the email alert & select the Decision name -> Done

Fig. 16: To Connect Decision

Save -> Activate the flow.

Create the record to satisfy the decision condition so that will receive the email. You can see the results as follows :

Fig. 17: Record For Test
Fig. 18: Result

3. Scheduled Triggered Flow:

  • A schedule-triggered flow starts at the specified time and frequency. You can’t launch a schedule-triggered flow by any other means.
  • The Start Time field value is based on Salesforce org’s default time zone.

We are creating a schedule triggered flow that executes daily from starting date of 22nd July at a specific time this will trigger the email

From the new flow window, we will select Scheduled Triggered Flow

Fig. 19: Schedule Triggered Flow

Then we have to select start date -> start time (as per org. time zone) & select frequency once, daily, or weekly as per need.

Fig. 20: Set a Schedule

select the object -> click on done.

Fig. 21: Select Object

Next we create a formula for flow as 7 days prior so 7 days before the expiry date will receive the email.

Fig. 22: Create Formula

Data type is Boolean, every day the flow will check the formula & if it’s 7 day before the expiry date then it will trigger the email.

Fig. 23: Formula for 7 days before

Select the decision box & add conditions according to your requirement like below.

Fig. 24: Decision conditions

To add more decision conditions click on + symbol.

Fig. 25: To add multiple decision

now, we have added another condition for 1 day prior & created a similar formula as shown above.

Fig. 26: 1 day prior decision condition

We will drag action for email & select filter by -> Type -> Email Alert -> search for email template -> Done.

Fig. 27: Email Action

Once you click on done then enter label name for 1 week prior email action & set input value as Record.Id then click on done then through connectors connect the proper decision condition with email action. Repeat the same process for 1-day prior email action as shown below.

Fig. 28: View of Flow

The following are the results of 1 week prior & 1 day prior

Fig. 29: Results of 1 week prior
Fig. 30: Results of 1 day prior

Best Practices for Creating Flows :

Some of the best practices to be followed when creating flows are:

  1. Plan the Flow: Understand the business process that needs to be automated using the flow. Draw the step-wise details required; this will help determine what elements and actions the flow needs. It would also help to understand how or when the flow is initiated.
  2. Create and Test the Flow: Create and test the flow in the Sandbox or developer environment before production. Creating the flow directly into production creates a risk of creating/modifying or deleting data in production.
  3. Perform Data Manipulation: Flows run under Apex governor limits; it is wise to combine all the data manipulations (create, modify or delete) and perform them at the end of the flow.
  4. Do Not Hardcode Ids: Ids are org-specific and will cause an error in the Flow execution when deployed to other environments.
  5. Save the Flow Regularly When Creating: Flows are not saved automatically. In case of session time out or internet issues, one can lose the developed flow unless explicitly saved. So it is recommended to save progress regularly.
  6. Always Build an Error Handler: Include a fault path in the flow design to gracefully handle an error in the flow and show custom error messages.
  7. Test Possible Paths the Flow Can Take: In the case of complex flows, the flow can take multiple paths depending on the data and decisions configured. Make sure to test as many paths as possible.
  8. Ability to Navigate to the Previous Screen: Avoid giving users the functionality to move backward in the flow. This can cause the flow to make duplicate data changes in the database if not handled carefully.
  9. Break down into sub-flows: Try to break down bigger flows into smaller flows as per business logic, so that it's easy to manage later on. Try to keep each flow small so we can also reuse a particular flow, if required.

Why Flows are better than Workflow Rules & Process Builders?

A flow is an application that automates a business process by collecting data and doing something in your Salesforce org or an external system.
Unlike workflow rules, which always execute behind the scenes, flows can provide screens to guide users through your business process.

Flows can launch a series of flows depending on the results of the previous one. Process Builder can trigger a flow,
but it is less powerful and can’t launch a process based on another process.

That’s why “Salesforce to Retire” Workflow Rules and Process Builder

Conclusion :

Now, You can process your business smoothly in an automated manner without worrying about the nitty-gritty with the help of Salesforce Flows.
It can collect all the data and function accordingly. Create posts for you, send emails, build records and delete them, update the necessary data and records and create events.

You can easily implement the functionality with the help of Screen Flow, Record Triggered Flow and Scheduled Triggered Flow in the next upcoming blogs will see the remaining Auto launch Flow & Platform event-triggered Flow. Till then you can enjoy building these flows.

Let me know in the comments, which flow you will prefer to achieve the amazing functionality.

--

--