What are the formulas in Salesforce?

What are the formulas in Salesforce?

Formulas are robust tools that enable users to perform calculations and other operations on their organization’s data. With formulas, users can embed hyperlinks, perform arithmetic with existing fields, or use conditional logic to display an amount.

 Checkbox Type in Formulas

A Checkbox Formula is a logical statement that’s either true or false. For example: If a user wants to know if an account has at least 500 employees on it, he or she can make use of a simple checkbox formula.

NumberOfEmployees >= 500

If an account has more than or equal to 500 employees, the checkbox Large Account is checked on that account’s page. Otherwise, a Large Account is not checked.

Formula Data types

  1. Checkbox: Calculate a boolean value.
  2. Currency: Calculate a dollar or other currency amount and automatically format the field as a currency amount.
  3. Date: Calculate a date, for example, by adding or subtracting days to other dates.
  4. Date/Time: Calculate a date/time, for example, by adding a number of hours or days to another date/time.
  5. Number: Calculate a numeric value.
  6. Percent: Calculate a percent and automatically add the percent sign to the number.
  7. Text: Create a text string, for example, by concatenating other text fields.

Features of Salesforce Formula fields

  • Perform calculations between multiple number fields.
  • Display data on a child object from the parent object.
  • Link and manipulate fields.
  • Calculate a certain date between two date fields.
  • Display different images if a certain criterion is true.

Uses of Formulas

  1. Approval Processes – Define the criteria that a record must meet to enter the approval process.
  2. Approval Steps – Define the criteria a record must meet to enter the approval step.
  3. Assignment Rules for Leads and Cases – Define the criteria the lead or case must meet for it to be assigned.
  4. Auto-Response Rules for Leads and Cases – Define the criteria a lead or case must meet to trigger an auto-response rule.
  5. Case Escalation Rules – Specify the criteria a case must meet for it to be escalated.
  6. Custom Buttons and Links – Define the content for custom links and buttons.
  7. Workflow Rules Define the criteria a record must meet to trigger a workflow rule.
  8. Visualforce Pages – Define the content for Visualforce pages.

Formula Operators 

The users can utilize these operators and functions for building formulas. All functions are available to include them in a formula like formula fields, validation rules, approval processes, and workflow rules.

Math Operators

  1. Add (+) – It calculates the sum of two values.
  2. Subtract(-) –  It calculates the difference of two values.
  3. Multiply(*) – It multiplies its values.
  4. Divide(/) – It divides its values.
  5. Open Parenthesis and Close Parenthesis () – It specifies that the expressions within the open parenthesis and close parenthesis are evaluated first.

Text Operator

  1. Concatenate(&) – It joins two or more strings.

Logical Operators

  1. Equal = and ==  – It evaluates if two values are equivalent. 
  2. Not Equal <> and !=  – It evaluates if two values are not equivalent.
  3. Less than<  – It evaluates if a value is less than the value that follows this symbol.
  4. Greater than>  – It evaluates if a value is greater than the value that follows this symbol.
  5. Less than or equal <= – It evaluates if a value is less than or equal to the value that follows this symbol.
  6. Greater than equal>=  – It evaluates if a value is greater than or equal to the value that follows this symbol.
  7. AND && – It evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.
  8. OR || – It evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR.

Conclusion

Formulas are an amazing way to calculate something, create validation rules, combine data from multiple fields, to check a condition,define workflow criteria, to display information from one record on a related record. Formula fields are based on other fields values that are shown only in detailed view of an object and can not be viewed in editable view of an object.

Leave a Reply