gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Give me a salesforce formula that checks if a variable, Test__c, contains letters
- User
Give me a salesforce formula that checks if a variable, Test__c, contains letters
- Assistant
In Salesforce, you can use the
REGEXfunction to check if a string contains letters. The formula below will check if the variableTest__ccontains at least one letter (either uppercase or lowercase):NOT(ISBLANK(Test__c)) && REGEX(Test__c, ".*[a-zA-Z].*")Explanation:
NOT(ISBLANK(Test__c)): This checks thatTest__cis not empty.REGEX(Test__c, ".*[a-zA-Z].*"): This uses a regular expression to check if there is at least one letter (a-z or A-Z) in the string..*allows for any characters before or after the letters.
You can use this formula in a validation rule, formula field, or anywhere else you need to perform this check in Salesforce. If this formula evaluates to
true, thenTest__ccontains at least one letter.