The CONTAINS function compares 2 text strings and is commonly used in validation and workflow rules to search for a character or string in a text field. For more information, please review CONTAINS and Formula Operators and Functions by Context (right-click links and open link in a new tab).
1. Search for text.
2. Check if an unknown string or character matches a defined set of strings or characters.
Example of searching for text.
CONTAINS(Comments__c,"BadWord") Returns TRUE if "BadWord" is found anywhere in Comments__c.
Example of searching for unknown string or characters.
CONTAINS("0123456789", TextField__c)
Will return true for TextField__c values such as 1,2,9,01,789, or any other substring of "0123456789"
CONTAINS("0123456789", LEFT(TextField__c,1))
To only match numbers 0-9, the compare_text length must equal 1. In this case, the formula is checking to see if the first character of TextField__c is a number between 0-9.
When using CONTAINS to compare a string with a defined set the length of the elements of the set should match the length of the string being compared. However, it's still possible to match the delimiter. An equivalent CASE statement would be longer but more reliable.
Note: The CONTAINS function considers BLANK value as true. Include NOT(ISBLANK() along with CONTAINS to meet requirements. If using NOT on CONTAINS, it does not recognize BLANK values.
000385300

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.