Get started with Flows in Salesforce!
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 :
- 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
Let us create a flow As you click on “Quick Find box” search for “Flows” and click on “New Flow” !
Select the flow as per your requirement :
Different Types of Flows:
- 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.
- Record Triggered Flow: It begins when a record is created or updated. Its functionality is similar to Process builder.
- Scheduled Triggered Flow: It runs automatically on a recurring schedule. It is helpful for jobs performed frequently or on a schedule (once, daily, weekly).
- Auto launch Flow: These can be called Apex, Process Builder, or another Flow. They can perform actions automatically behind the scenes.
- 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.
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.
Interaction Elements :
- 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.
- Actions: Actions are external actions that further extend the functionality of the flow. Some examples of actions — Apex, Send emails, etc.
- Subflow: A flow can initiate another flow.
Logic Elements :
- Decisions: Decisions split the flow depending on the data that’s being sent through the decision element.
- Assignments: Assignments give a value to a variable.
- 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.
As you can see edit screen window is opened we have to click on Display Text.
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.
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.
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”
Click on Scheduled Paths to configure it according to offset number and offset options.
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.
Next, we will drag the decision from the logic section & add all the conditions which are required.
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.
For email, drag & drop Action element then filter by -> type -> email alert ->search the email template -> Done
Let’s set the input value as Record.Id then click on done.
Next, we will connect the decision box with the email alert & select the Decision name -> Done
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 :
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
Then we have to select start date -> start time (as per org. time zone) & select frequency once, daily, or weekly as per need.
select the object -> click on done.
Next we create a formula for flow as 7 days prior so 7 days before the expiry date will receive the email.
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.
Select the decision box & add conditions according to your requirement like below.
To add more decision conditions click on + symbol.
now, we have added another condition for 1 day prior & created a similar formula as shown above.
We will drag action for email & select filter by -> Type -> Email Alert -> search for email template -> Done.
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.
The following are the results of 1 week prior & 1 day prior
Best Practices for Creating Flows :
Some of the best practices to be followed when creating flows are:
- 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.
- 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.
- 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.
- Do Not Hardcode Ids: Ids are org-specific and will cause an error in the Flow execution when deployed to other environments.
- 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.
- 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.
- 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.
- 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.
- 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.