2

I'm trying to create formula field which returns 1 when text field CONTAINS certain text, else 0. E.g. if text field "City" CONTAINS NY or New York or NewYork, then it should return 1 else 0.

I'm able to achieve this using EQUALS as follows. But I want to use CONTAINS. Can someone please help, how to use CONTAINS or any other solution that searches particular text within a text field and returns NUMBER?

if (City= "NY" || City = "New York" || City = "NewYork", 1, 0) 

I tried this as well but it gives error "Incorrect number of parameters for function 'if()'. Expected 3, received 5".

if (CONTAINS(City,"NY"),CONTAINS(City,"New York"),CONTAINS(City,"NewYork"),1,0) 

3 Answers 3

1

You can have a combination of OR and IF like this.

if (OR(CONTAINS(City,"NY"),CONTAINS(City,"New York"),CONTAINS(City,"NewYork")),1,0) 

Here your IF logic will be calculated on OR basis and if you City has any one of the three text, it will result in true and return 1, orelse 0.

1
  • Thanks. Your solution worked Nagendra Singh.
    – NikM
    Jul 27, 2021 at 8:51
0

Can anyone help to correct this , if my code snippet is wrong: I am using Contains keyword in Classic HTML Email Templates, i need to display dynamic values based on if Condition inside myCar(); example: myCar(MARUTHI 156);

myCar({!IF(CONTAINS(Case.Engine_Model_Db__c ,"MARUTHI")),"MARUTHI 156","{!IF(CONTAINS(Case.Engine_Model_Db__c,"SWIFT")),"SWIFT A1","False"}"})

Thanks in Advance sfdclearner

1
  • 1
    Welcome to Salesforce Stack Exchange (SFSE)! This is a Questions & Answers site, not a threaded forum. Please see the various pertinent/relevant notes in Why and how are some answers deleted?, and be aware that your "answer" will likely be deleted. You could ask a new question, and in it you can link to this question or its other answer for reference (just click "Share" at the bottom left of the post to get a URL).
    – Moonpie
    Sep 16, 2022 at 13:28
-1

Can anyone please help me to solve this problem. I have a website field in accounts page layout where i wanted to eliminate if website contains either "HTTP" or "WWW" or numbers 0-9 or special characters through the validation rule. Request you to please help!

1
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – Derek F
    Dec 14, 2022 at 11:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .