SOSL will be used to search the text string all across the object and around the field. Salesforce Object Search Language is what you're looking for. It is capable of searching for a specific string throughout various items.
SOSL statements return a list of sObjects, with each list containing the search results for a specific sObject type. The outcome lists have always been decided to return in the direction determined in the SOSL query.
SOSL is often used to build text-based search queries that are then run against search index. In the following environments, we could indeed search email, text, and phone number fields for various Items through including custom objects because we have direct exposure to to include in a single instance:
Wish to make a career in the world of salesforce? Start with HKR'S salesforce online training !
The database is a collection of tables that hold data. Using SOQL and SOSL querying in Salesforce, it is simple to fetch or retrieve data from a database.
SOQL stands for Salesforce Object Query Language.
SOSL is an abbreviation for Salesforce Object Search Language.
The two languages mentioned above assist us in dealing with databases and retrieving the necessary data.
Logic = Apex Code.
Apex Code is made up of logic and the ability to fetch data.
A SOSL query begins with the FIND clause. We would then need to execute clauses to the query to filter the object type, data, and fields. We can also control what is returned. A SOSL query is enquired in the format shown below.
Get ahead in your career with our salesforce Tutorial
Find:It clarifies the text (words or phrases) to be searched.
In Search Group: This specifies the scope of the fields to be searched. It goes into greater detail about the search. It could have the following values:
Returning: This is the data that will be returned in the search results. Following this keyword, a list of one or more objects could be stipulated. If we miss this, the results will comprise the Ids of all sObjetcs discovered.
LIMIT: This determines the maximum number of rows that will be decided to return by the query. If this parameter is left blank, the default value is 200, which is the maximum number of rows which can be returned.
Click here to get frequently asked Salesforce interview questions & answers
We can perform the test in two ways. They are:
Steps: Log in to the Salesforce Developer Console. Press the bottom arrow of the window, then select the "Query Editor" tab, enter the code, and click "Execute."
Steps in creation of SOQL Apex class:
Log in to Salesforce org → Developer Console → Ctrl + E → Write the code and execute.
Steps to create SOSL apex class:
Login to Salesforce org → Developer Console → Ctrl + E → Write the code and execute.
Declaring of list of list type variable:
> ListOfResults = new list<list >();
ListOfResults = [FIND 'Blonde' IN ALL FIELDS RETURNING Naukri_com_JobForm__c(First_Name__c LIMIT 2), Levis__c(Price__c WHERE Price__c > 500 ORDER BY Price__c)];
system.debug('The Results=' + ListOfResults );
//add additional code for List Seperation of Output
ListA = new list ();
ListB = new list ();
ListA = ListOfResults;
ListB = ListOfResults;
system.debug('The Result in List A =' + ListA);
system.debug('The Result in List B =' + ListB);
In the above blog post we had discussed about the SOSL in salesforce in depth. Had any doubts drop yourquieres in the comment section to get them resolved. Happy learning!
Batch starts on 13th Feb 2023, Weekday batch
Batch starts on 17th Feb 2023, Fast Track batch
Batch starts on 21st Feb 2023, Weekday batch
28th February | 07:00 pm