While working at a company that uses Salesforce CRM, I was tasked with reviewing customer reviews and, based on them, handling urgent case situations.
As a solution, I found the Salesforce FIND() function. So, if you want to know how to find the position of a search text string in the text or how to use the FIND function with real-life business examples, go through this complete article.
In this tutorial, we will learn how to find the position of a search string within a text field using the FIND() function in Salesforce.
What is the FIND() Function in Salesforce?
FIND() Function in Salesforce is one of the available TEXT() Functions in Salesforce, which is used to perform text operations on the fields. This FIND() Function returns the position of the search text string as a number.
In addition, the following is the syntax of the Salesforce FIND function:
FIND(search_text, text [, start_num])
Here is a detailed description of the parameters:
- search_text: The search_text parameter specifies the string or substring that you want to find.
- text: The text parameter specifies the field or expression in which you are searching for the substring.
- start_num: The start_num parameter specifies the starting number for the search. And this search process always begins at the left side of the string and proceeds to the right.
Moreover, several considerations must be kept in mind when using the Salesforce FIND() function.
- Remove brackets[]: If you are working with the Salesforce Find Function, always remember to remove the square brackets [] before validation. If you have not done this, you will get an error.
- Starting Character: In Salesforce Find Function, the first character of the string is represented as zero rather than one.
- Blank text Parameter: The Salesforce formula field displays zero if you are using the Find Function and don’t pass any field or expression in your text parameter.
- Unique start_num Parameter: In some cases, the start_num parameter behaves differently. For example, if you use this Find Function in the field containing the website name, the start_num parameter behaves differently because the http:// is automatically added to the beginning.
- Case Sensitive: The search_text parameter is case-sensitive in nature, which means the Lower and Upper Case characters behave differently.
- Zero as Result: The zero is displayed as the result of the field where you use the Find Function function, and the start_num parameter value is greater than the length of the text.
- Wild Characters: If you are working with the Salesforce Find Function, note down one thing: the search_text parameter cannot contain any wildcard character.
- Negative start_num: The zero is displayed as the result of the formula field where you have used the Find Function if the start_num parameter is not greater than 0, i.e., a negative number.
- No Result Cases: If the Find Function does not return the search result, a zero is displayed in the field.
- Optional Parameter: In the Salesforce Find Function, the start_num parameter is optional. The function uses the first character of the string if you don’t pass any value to the start_num.
In addition, keep in mind that the provided text field parameter must be of the TEXT field type while using this function. You will encounter an error if you give the function any other field type as an argument.
Let’s look at a simple example of the FIND() function before proceeding to a better understanding of the topic.
Suppose you are working in the marketing team of a company that uses Salesforce as the tool, and you have to assign the lead to the marketing campaigns based on the description of the lead. And for this, you also have to use the FIND Function of Salesforce, so here is the formula:
IF(FIND('Google Ads', Lead_Description__c) > 0, 'Google Ads', IF(FIND('Twitter', Lead_Description__c) > 0, 'Twitter', 'Newspaper'))
With this, we have learned the basics of the FIND function, including its syntax and key considerations. We have also learned just a small example to understand it deeply.
Now, we will move on to the next topic and learn how to use the FIND() Function in Salesforce Lightning and Classic to fi