"Beginner's Guide to Using Flows in Salesforce for Business Automation"

 


Flow is a powerful automation tool for businesses that enables the collection, creation, updating, editing, and deletion of Salesforce data while executing logic and guiding users through data collection and updates. By simplifying complex business processes, Salesforce flows can prevent confusion and chaos. They can also be used to perform tasks such as sending emails, posting on Chatter, and sending custom notifications. Flow can be triggered by record insertion, updates, and deletion, and can run for both before and after events. 

There are different types of flows available including 

  1. Screen Flow. 
  2. Record Triggered Flow. 
  3. Schedule-Triggered Flows.
  4. Auto Launch Flows.
  5. Platform Event Triggered Flow.
Fig. 1: Hierarchy of Flow


To create a flow, begin by clicking on the "Quick Find box" in Salesforce and searching for "Flows." Next, select "New Flow" to start creating your new flow.

Fig. 2: Creating a New Flow

When selecting a flow in Salesforce, it's important to consider the specific requirements of your business processes. 

Here are some guidelines to help you select the right flow:
  1. Screen Flow: Use this flow if you need users to interact with the UI and enter data or select records.
  2. Record Triggered Flow: Use this flow if you need to automate actions based on record creation or update.
  3. Scheduled Triggered Flow: Use this flow if you need to perform tasks on a regular schedule, such as daily or weekly.
  4. Auto Launch Flow: Use this flow if you need to trigger actions automatically based on other processes, such as Apex or another flow.
  5. Platform Event-Triggered Flow: Use this flow if you need to perform actions based on specific events occurring in the system.
After clicking on "New Flow" you will be presented with a menu of different flow types to choose from. Select the flow type that best suits your needs:

Fig. 3: Flow Types

When you select a flow type and the "Free-Form" option is enabled, you will see a canvas for designing your flow in the center of the screen. On the left-hand side of the screen, under the "Elements" tab, you will find three categories of elements:

  1. Interaction Elements: These elements allow you to create screens and collect user input, such as text input or record selection.
  2. Logic Elements: These elements allow you to define the logic of your flow, such as decision-making, branching, and looping.
  3. Data Elements: These elements allow you to access and manipulate data in your flow, such as creating, updating, or deleting records.
Fig. 4: Element Tab View (Free Form is enabled)

The different types of elements that can be used to create a flow are:

Interaction Elements:
These elements are used to create a user interface for the flow, and they include:
  • Screen: This element creates a screen for the flow that can display information or collect data from the user. It is available only in Screen Flows.
  • Actions: These are external actions that extend the functionality of the flow, such as Apex actions, sending emails, or creating records.
  • Subflow: This element initiates another flow from within the current flow.
Logic Elements: 
These elements are used to define the logic of the flow, and they include:
  • Decisions: These elements split the flow based on the data being sent through them.
  • Assignments: These elements assign values to variables used in the flow.
  • Loops: These elements handle multiple variables at once using collections.
Data Elements: 
These elements allow the flow to interact with Salesforce data, and they include:
  • Get Record: This element fetches records from the database.
  • Create Record: This element creates records in the database.
  • Update Record: This element updates records in the database.
  • Delete Record: This element deletes records from the database.
Connectors: 
These elements connect different elements in the flow and determine the available paths that the flow can take at run time. Some types of connectors include:
  • Unlabeled: This connector does not have a label or condition associated with it.
  • Decision Outcome: This connector is associated with a decision element and represents the possible outcomes of the decision.
  • Fault: This connector is used to handle errors in the flow.
  • Pause: This connector pauses the flow for a specified amount of time.
  • For Each: This connector loops through a collection of records or variables.

1. Screen flow:

Once you have selected "Screen Flow" from the new flow window, you can add a screen element to display a customized welcome message to the user. Follow these steps:
  • Click on the "Screen" element from the "Add Element" section on the left-hand side of the screen.
  • If the "Auto-Layout" option is enabled, you will see the screen element added to the canvas automatically.
  • Double-click on the screen element to edit it.
  • Enter the welcome message you want to display to the user in the "Title" field.
  • In the "Subtitle" field, you can add additional text or instructions for the user.
  • You can also add any desired fields to the screen by clicking on the "Fields" tab and selecting the appropriate fields from the list.
  • Once you have finished customizing the screen, click "Save" to save your changes.
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 the 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 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

To create a Record Triggered Flow, you can follow these steps:
  • Click on the "New Flow" button.
  • Select "Record-Triggered" as the flow type.
  • Select the object on which you want to create the flow.
  • Select when the flow should be triggered, either "When a record is created" or "When a record is created or edited".
  • Click on the "Save" button.
  • Once you have created the flow, you can add elements to it based on your requirements. For example, you can use the "Get Records" element to retrieve data from the object, the "Create Records" element to create new records, or the "Update Records" element to update existing records.
Remember to activate the flow once you have finished creating it.

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

To add a connector between the Start element and the Decision element, we can click on the Start element and drag the connector line to the Decision element. Then, we can select the Scheduled Path by clicking on the connector and choosing "The 6 months Prior Business Record Reminder" from the drop-down list. Finally, click on Done to save the changes.

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

After clicking on "done," you should provide a label name for the email action that will occur one week prior and set the input value as Record.Id. Then, connect the appropriate decision condition with the email action using connectors. This process should be repeated for the email action that will occur one day prior, as demonstrated 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 :

Here are some best practices to follow when creating flows:
  1. Plan the flow: Before starting, understand the business process that needs to be automated and draw a step-by-step plan for the flow. This will help determine the necessary elements and actions the flow requires, as well as when and how the flow is initiated.
  2. Create and test in Sandbox: Develop and test the flow in a Sandbox or developer environment before deploying to production. Building the flow directly in production increases the risk of creating, modifying, or deleting data.
  3. Perform data manipulation at the end: Flows run under Apex governor limits, so it's best to combine all data manipulations (create, modify, or delete) and perform them at the end of the flow.
  4. Avoid hardcoding Ids: Ids are specific to an org and can cause errors during Flow execution when deployed to other environments.
  5. Save progress regularly: Flows are not saved automatically, so save progress frequently to avoid losing work due to session time-outs or internet issues.
  6. Include an error handler: Create a fault path in the flow design to gracefully handle errors and display custom error messages
  7. Test all possible paths: For complex flows, the flow can take multiple paths depending on data and decisions. Test as many paths as possible.
  8. Avoid backward navigation: Avoid giving users the option to move backward in the flow, as it can cause duplicate data changes in the database.
  9. Break down into sub-flows: If the flow is complex, break it down into smaller, manageable sub-flows. Keep each flow small to make it easier to manage and potentially reuse if needed.

Why Flows are better than Workflow Rules & Process Builders?

Flows are better than Workflow Rules and Process Builders for several reasons:
  1. More powerful automation: Flows provide more powerful automation capabilities compared to Workflow Rules and Process Builders. They can perform complex data manipulations, execute multiple actions, and launch other flows based on specific conditions.
  2. User-friendly: Flows offer a user-friendly interface that can guide users through complex business processes. Workflow Rules and Process Builders do not have this feature, and users may need to be trained on how to use them.
  3. Improved data visibility: Flows can collect data from users through screens, making it easier to track and report on the data. This feature is not available in Workflow Rules and Process Builders.
  4. Better integration capabilities: Flows can integrate with external systems, while Workflow Rules and Process Builders have limited integration capabilities.
  5. More future-proof: Salesforce is planning to retire Workflow Rules and Process Builders in the future, which means that Flows will be the go-to automation tool in Salesforce. Therefore, it makes sense to start using Flows now to future-proof your automation efforts.
Overall, Flows provide more flexibility, power, and user-friendliness compared to Workflow Rules and Process Builders, making them the preferred choice for automating business processes in Salesforce.

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:

Salesforce Flows allow you to automate your business processes seamlessly, taking care of all the details so you don't have to. It can gather and process all the necessary data, and perform a wide range of tasks like generating posts, sending emails, creating and deleting records, updating relevant data and records, and scheduling events.

By utilizing Screen Flow, Record Triggered Flow, and Scheduled Triggered Flow, you can easily incorporate these features into your business operations. In the upcoming blogs, we will also explore Auto Launch Flow and Platform Event-Triggered Flow. For now, you can enjoy building your own flows and streamlining your business processes.

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

Comments

Post a Comment

Popular posts from this blog

"Mastering the Approval Process Object in Salesforce: Everything You Need to Know"

Salesforce Vlocity: Revolutionizing the Customer Experience!