Use Formulas in Salesforce Flow: Explained with Examples : Bijay Kumar
by: Bijay Kumar
blow post content copied from SalesForce FAQs
click here to view original post
### Summary of Using Formulas in Salesforce Flow In Salesforce Flow, formulas are used to simplify complex logic by allowing users to check multiple conditions at once, rather than using multiple decision elements, which can make the flow confusing and lengthy. This tutorial explains how to effectively use formulas in Salesforce Flow, including where to apply them, important functions, and practical examples. #### Key Details: - **Purpose of Formulas**: Formulas help in writing logic that checks conditions, performs calculations, or generates text values. - **Creating Formulas**: Users can create formulas in Flow Builder to streamline decision-making processes. - **Examples**: 1. **Entry Conditions**: Use formulas to trigger flows based on specific criteria, such as checking if an account's industry is "Technology" and its priority is either "High" or "Urgent." 2. **Decision Elements**: Formulas can simplify conditions for sending reminders, such as checking if a contract's end date is within 30 days and its status is "Active." 3. **Assignment Elements**: Formulas can dynamically generate messages based on opportunity amounts, allowing for customized discount messages. #### Steps to Create Formulas: 1. Navigate to **Setup** and open the **Developer Console**. 2. Use SOQL queries to retrieve available formula functions. 3. Create a new formula resource in Flow Builder, selecting the appropriate data type. 4. Write the formula using logical operators and functions. 5. Use the formula in decision or assignment elements to control flow actions. #### Conclusion: Using formulas in Salesforce Flow enhances clarity and efficiency, enabling users to implement complex business logic without cluttering the flow with multiple decision elements. ### Additional Context: Understanding how to effectively use formulas in Salesforce Flow can significantly improve workflow automation and data management. This is particularly useful for businesses looking to streamline their processes and reduce manual errors. ### Hashtags for SEO: #Salesforce #SalesforceFlow #Formulas #Automation #BusinessLogic #FlowBuilder #SalesforceTutorial #SOQL #ProcessAutomation #CRM #SalesforceTips #SalesforceDevelopment
While developing the flow, I needed to update a field based on some conditions, such as record type and status. There, I used multiple decision elements, which made the flow too long and confusing.
To solve this, I used a formula to check all the conditions simultaneously. This made the flow cleaner and easier to understand.
In this tutorial, we will learn how to use formulas in Salesforce Flow. I will explain where we can use formulas in Flow, important formula functions, and a list of all available formulas for Salesforce Flow, along with real-time examples and explanations.
Why We Use Formulas in Salesforce Flow?
A formula in Salesforce Flow is a way to write logic using fields, functions, and operators to generate a result, such as checking a condition, performing a calculation, or generating text values.
List of All Available Formulas For Salesforce Flow
Now, let’s review the formula functions available in Salesforce Flow. For that, we will write an SOQL query to display the formulas.
Below, I will explain the steps to retrieve the formulas and functions that are used in Salesforce Flow:
- Click Setup -> Developer Console.
- In the Query Editor, enter the following SOQL query:
SELECT Function.Name, Function.Label, Function.Description, Function.ExampleString
FROM FormulaFunctionAllowedType where Type='Flow'
- Select the Use Tooling API checkbox.
- Click Execute.
In the image below, you can see the SOQL query result. It displayed the column that we provided in the query, and we can see the function that we can use in Salesforce flow, the description, and the syntax to use in the formula editor.

Create and Use Formulas in Salesforce Flow: Examples and Explanations
Now, we will learn where we can create and use formulas in Salesforce Flow, including important functions for numbers, text, dates, and logic implementation, as well as how to utilize them in Action and Decision elements.
Example 1: Use a Formula in the Flow Set Entry Condition
When using the Record Trigger Flow, in the Start element, we add the Object and also set the entry conditions. While adding these conditions, we cannot add the Formula Resource in the value field.
However, we can now select “Formula Evaluates to True” in the Condition Requirement option. There, we can create a formula and add to the value field.
Use Case:
You are implementing a flow to automate the process that should trigger only when an account is updated to “Technology” industry, but only if the Priority is also “High” or “Urgent”.
In “All Conditions Are Met“, we can’t group conditions like this (combine AND + OR together). It treats each line as a simple AND condition, so you cannot say “either High or Urgent”.
In the image below, you can see that when we select the Condition Requirements, we can only choose either the AND or OR condition. We cannot use them together.

This is why we need to use a formula. Here, it helps prevent the flow from running when the status hasn’t actually changed, which improves the system’s performance.
It also ensures that the flow runs only for important cases, such as when the priority is set to High or Urgent.
A formula enables us to check all these things straightforwardly, using logical operators such as ISCHANGED, AND, and OR, which we can’t easily do with the standard “All Conditions Are Met” option.
Create and Use Formulas in the Flow Set Entry Condition:
If we try to use “All Conditions Are Met”, we would need multiple lines and might not be able to combine all conditions correctly. Instead, we can use a formula in the Set Entry Conditions like this:
AND(
ISCHANGED(Industry),
ISPICKVAL(Industry, "Technology"),
OR(
ISPICKVAL({!$Record.Account_Priority__c}, "High"),
ISPICKVAL({!$Record.Account_Priority__c}, "Urgent")
)
)
To use the formula, select the “Formula Evaluate to True” option, and then we can create formulas for complex business logic that cannot be provided in simple conditions.

In this way, we can create and use formulas in the Flow set entry condition in Salesforce to implement complex business logic conditions.
Example 2: Use Formula With Decision Element in Salesforce Flow
Now we will understand how to create a formula resource that we can use in values to filter records or add conditions in Salesforce flows.
Formula resources in Flow are like variables, but we can’t set the formula value ourselves. They are read-only, which means their value is automatically calculated based on the formula we write.
Just like formulas in custom fields, Flow formulas operate similarly to those in Excel. We can use fields, functions, and operators to perform tasks such as mathematical calculations, text transformations, or logic checks.
Use Case:
Suppose a company wants to send a renewal reminder email, but only under specific conditions:
- The contract End Date is within the next 30 days.
- The contract Status is “Active”.
- And the Customer Type__c (Custom Picklist Field) is not “Trial“.
While building the flow, adding these conditions separately in the Decision Element makes the logic look messy and more challenging to manage.
To simplify this, I use a formula that combines all these checks into a single, clean formula, making the flow more straightforward to maintain and understand.
Create Schedule Trigger Flow:
Here we have the Contract object in Salesforce. The Contract End Date is calculated based on the Contract Term (in months). Now we want to send a reminder email to those contracts whose end date will be within the next 30 days.

Navigate to the setup, and in the Quick Find box, search for ‘Flows’ under Process Automation.
In the flows setup window, click on the button New Flow. Select the option Schedule-Triggered Flow, and click Create.
Select the Start Date and Start Time for the schedule of the trigger flow. After this, select the frequency from the options: Once, Daily, and Weekly.

Create a Formula Resource in Salesforce Flow:
Now we need to create the formula resource, which we will use to check the conditions for sending the reminder email.
To create a formula in Flow Builder, click on “New Resource” in the Toolbox. Then choose “Formula” from the Resource Type dropdown. After that, provide the API Name and select the data type.
Here we will select Boolean as the Data Type because we want to send the email if the condition is true.

Next, you’ll see the screen where you can write your formula. If this formula evaluates as true, then the next step will be executed.
AND(
TODAY() + 30 >= {!$Record.EndDate},
ISPICKVAL({!$Record.Status}, "Activated"),
NOT(ISPICKVAL({!$Record.Customer_Type__c}, "Trial"))
)
Below, I have explained the above formula:
- TODAY() + 30 >= {!$Record.EndDate}:
- This checks if the contract will end within the next 30 days.
- TODAY() is the current date.
- TODAY() + 30 means 30 days from now.
- If the End Date is before or equal to the current date, it means the contract is ending soon.
- ISPICKVAL({!$Record.Status}, “Activated”):
- This checks if the Status of the contract is exactly “Active”.
- ISPICKVAL() is used to check the value of picklist fields.
- NOT(ISPICKVAL({!$Record.Customer_Type__c}, “Trial”):
- This checks that the Customer Type is not “Trial”.
- The flow should only run for paying or regular customers, not for trial accounts.

After creating the formula, we need to add a decision element that checks if the created formula returns true. If it does, we can send the reminder email.
If the formula gets false, then the Default Outcome will be executed.
After adding the decision element, provide the Label and API Name. Next, add the Outcome Label as per your requirement.
Select the Formula Resource that we created in the Resource field. In Operator, select Equals, and Value is True.
This condition says that if the formula that you created is true, then the next step will be executed.

If the condition is true, the Send Email action will be executed, sending a reminder email to the customer.
After sending an email, we will update the ‘Reminder Sent‘ checkbox field to True. That will indicate a reminder has been sent to this contract owner.
Now we are ready to save the flow. For that, click the Save button, provide the flow Label, and the API Name will be automatically populated.
After that, always debug the flow before activating it to ensure that the working flow is correct and that there are no runtime errors. Then activate the flow.

In this way, we can create a new formula resource and a formula with a decision element in Salesforce Flow.
Example 3: Use Formula WIth Assignment Element in Salesforce Flow
Now, let’s see how the Assignment Element in Salesforce Flow allows us to set the value of a variable. We can use a formula inside the assignment element to calculate and assign values dynamically.
Use Case:
A software company offers different discount messages based on the Opportunity Amount. When a sales rep creates or updates an opportunity, the system should automatically generate a custom discount message and display it on the custom field named Discount_Message__c.
- If Amount ≥ ₹100,000 -> Message: “Eligible for 20% enterprise discount.”
- If Amount < ₹100,000 but ≥ ₹50,000 -> Message: “Eligible for 10% business discount.”
- Otherwise -> Message: “Standard pricing applies.”
Create Record Trigger Flow:
Create the Record Trigger Flow and configure the Start Element as follows:
- Object: Opportunity.
- Trigger: When a record is created or updated.
- Optimize the Flow For: Actions and Related Records.
Create a Formula Resource in Salesforce Flow:
Create a formula resource where we can add a condition to the opportunity amount field and also add a message according to the conditions.
For this Formula, which is one of the Resource Types, we have selected the Data Type as Text.

Next, we need to provide the formula and the message that we want to display according to the opportunity amount.
IF(
{!$Record.Amount} >= 100000,
"Eligible for 20% enterprise discount.",
IF(
{!$Record.Amount} >= 50000,
"Eligible for 10% business discount.",
"Standard pricing applies."
)
)
After adding the formula, always check the Syntax. If it is valid, you can click the Done button; if it is not, you need to make corrections to your formula.

After creating the formula, we need to create a Variable resource with a Data Type of Text that will hold the discount message received from the formula resource.

The discount message received from the formula resource, we need to assign to the Text variable that we created in the above step.

Then, finally, we need to update the discount message field in the opportunity object. For that, add the Update Record element and set the varDiscountMessage variable to the field of the opportunity object.

Proof of Concept:
In the opportunity object, you can see we don’t have any text in the Discount Message field. Now, as I update the Amount field and save the record, the discount message field automatically displays the message according to the condition we defined in the formula resource.

You can see that as I saved the record, the discount message is displayed.

In this way, we can use the formula with an assignment element in Salesforce Flow to set the value of a variable.
Conclusion
I hope you have an idea about how to use formulas in Salesforce Flow. I have explained where we can use formulas in Flow, essential formula functions, and a list of all available formulas for Salesforce Flow, along with real-time examples and explanations.
You may like to read:
- Flow User Checkbox vs Run Flows in Salesforce
- Fault Paths in Salesforce Flow
- Wait Element in Salesforce Flow
The post Use Formulas in Salesforce Flow: Explained with Examples appeared first on SalesForce FAQs.
June 25, 2025 at 10:43AM
Click here for more details...
=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Post a Comment