While working as a Salesforce Administrator, I was assigned the task of assigning an urgency rating to cases based on the case source’s first character.
So, as a solution, I found that Salesforce provides a function named BEGINS, which helped me assign ratings to cases based on the case source’s first character.
In this tutorial, we will learn how to use the BEGINS function in Salesforce to determine whether text begins with specific characters. We will also understand its syntax and a few real-world business-related useful examples.
What is the BEGINS() Function in Salesforce
The BEGINS() function is one of the Salesforce text functions used to perform text operations. In general, the BEGINS() function checks whether text begins with the specified characters; it returns TRUE if it does and FALSE otherwise.
Make sure of the following points while working on the BEGINS function:
- The BEGIN function is case-sensitive, so it treats the compare text differently for both lowercase and uppercase.
- Fields that are left blank when utilising this function in a workflow rule or validation rule are treated as valid. For instance, if a validation rule checks to see if an order starts with “56” all records with the blank order id number are accepted as valid.
Syntax and Usage of the BEGINS() Function in Salesforce
Below is the syntax of the BEGINS function in Salesforce:
BEGINS(text, compare_text)
Here:
- Text: It specifies the value or field that you want to check. It can be anything: a single plain string, text, or a reference to the text field.
- compare_text: It specifies the value of the prefix that we want to look at the beginning of the text value. It can be plain text enclosed in double or single quotes, a numerical value, or a field that has a compared value.
Let’s look at scenarios to understand the BEGINS function better.
As I discussed, I was assigned the task of assigning an urgency rating to cases based on the case source’s first character. So, here is the function-based formula with the use of the BEGIN function.
IF(
OR(
BEGINS(Case_Source, "Phone"),
BEGINS(Case_Source, "Email"),
BEGINS(Case_Source, "Lead")
),
10,
5
)
With this, we have learned the syntax of the BEGINS() function with a real-life-based scenario. Now, we will proceed to learn how to use the BEGINS() function in a Salesforce Lightning Component.
Use the BEGINS() Function in Salesforce
The following steps show how to use the BEGINS() function in Salesforce.
- Go to the “Gear Icon”. Then click the “Setup“.

- The setup page opens when you select the Setup option. Here, the “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.

- The object manager page opens when you click it. There are numerous objects seen here. Use the Quick Find Search