Salesforce SOSL with CONTAINS

0 votes

I noticed apps on Salesforce that could perform run CONTAINS queries. The CONTAINS filtering is possible even with the basic list filter functionality on object lists.

I tried the following with SOSL:

List<List<SObject>> searchList = [FIND '*ben* AND *berlin*' IN ALL FIELDS 
                                  RETURNING Account(Name)];

I have an account name "BigBen" in "Berlin". I am not able to find this account using upper SOSL call. I tried different combinations, but no success. How do i do SOSL calls with CONTAINS? Using the basic list filtering i am able to use CONTAINS with "ben", it gives me the expected results.

Mar 28, 2022 in SalesForce by surbhi
• 3,810 points
604 views

1 answer to this question.

0 votes

Unlike SOQL, which uses the LIKE comparison operator to support wildcards anywhere in the search word, SOSL does not allow wildcards at the start of a search term (a "starts with" search).

In this scenario, where you're only looking for one sObject, SOQL might be a better option.

I hope this helps!

Sign up for the Salesforce training if you want to learn more about Salesforce SOSL.

answered Mar 29, 2022 by CoolCoder
• 4,400 points

Related Questions In SalesForce

0 votes
0 answers

Salesforce Apex SingleEmailMessage with Template to User not contact

Im trying to send an email in ...READ MORE

Feb 28, 2022 in SalesForce by surbhi
• 3,810 points
2,810 views
0 votes
1 answer

Salesforce Apex/JSON serialization with change on variable name

Apex does not support annotation for serialization. But, ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
3,516 views
0 votes
1 answer

Username/password JWT with Salesforce Named Credentials

Although Named Credentials cannot be used to ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
1,766 views
0 votes
0 answers

Can i create a sql table populated with Salesforce objects?

does Salesforce offer a way to obtain ...READ MORE

Mar 4, 2022 in SalesForce by surbhi
• 3,810 points
351 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
2,768 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
744 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
485 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 544 views
0 votes
1 answer

Salesforce Apex SingleEmailMessage with Template to User not contact

// Pick a dummy Contact Contact c ...READ MORE

answered Mar 17, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 27, 2023 by Khan Sarfaraz 3,989 views
0 votes
1 answer

salesforce how to login with javascript without security token

OAuth2 is a security protocol that allows ...READ MORE

answered Apr 1, 2022 in SalesForce by CoolCoder
• 4,400 points
891 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP