Get Upto 50% Offer | OFFER ENDING IN:0 D 0 H 0 M 0 S

Log In to start Learning

Login via

Post By AdminLast Updated At 2020-06-11
What is SOQL in Salesforce?

SOQL is used to make text-based Search Queries, on the search index SOSL. It is a search particular string from many objects. Every time it returns a list object. The output lists are every time return in the same sequence, as they were selected, in the SOSL query.

SOSL is like SOQL, but it searches records from many objects. That we can see in many objects, at the same time using SOSL. In SOSL, we can Query only a single object at a time, but in SOSL, the statements can not exceed more than 10,000 characters.

Know more about SOQL by Salesforce Online Training

1.SOSL Query starts with a keyword known as ‘FIND”.

2. At the same time, we can search a certain string like “US GLOBAL” in many objects.

3. It searches Record from Entire Database.

4. The result of SOSL is a sequence of sobjects “List>”

5. The changed result has a sequence of sobjects, in the same sequence as mentioned in SOSL Query.

6. If the SOSL query doesn't return any records, for a significant subject type, then the search output includes an empty sequence for that subject.

7. The search string is of two characters long.

8. You can search text, phone, email, and multiple objects.

9. The maximum batch storage is 2,000 records. REST Calls or SOAP, apex statements, getter methods, visual force controllers, schema explorer for the eclipse toolkit.

1.Salesforce Object Query language(SOQL):

A SOQL query is equal to SELECT SQL statement and identifies the org database. SOSL is a scripted way of operating a text-dependent search on the search index. Whether you use SOQL or SOSL depends on whether you know which objects you want to search.What is SOQL in Salesforce?| OnlineITGuru
2. When we have to implement SOSL?

Use SOSL, when you do not know what object or in where the data resides.

Getting Data for certain terms, that you exist within a field. SOQL can search in a faster way and they can change to more relevant results.

It searches the search text efficiently from many objects, whether they referred to every other or not.

3.Operation Considerations:

When you search general search terms, they slow or they return as many as results they can. Implement the following clauses for defining efficient text searches.

1.RETURNING: It searches from those fields and objects that mentioned and changed the result.

2.OFFSET: It shows the search results on many pages.

3.LIMIT: It defines many numbers of rows that return.

4.IN: It limits that type of field for searching, that contains email, mobile, and name.

4. Where SOSL is Used?

1.If we don’t know in what objects the data is shown.

2. We can get many objects and fields values, that efficiently works when the objects may or may not refer to each other.

3. We can search only those fields, what data types in email, mobile, and text.

4. We can implement classes, but not the triggers.

5. We cannot operate DML operations on search output.

List> accountSearchList =newList>();accountSearchList=[FIND {onlineITGuru}IN Name Fields RETURNINGlead (name, phone Where created date = THIS_FISCAL_QUARTERLIMIT 20) ];list accs;accs=(list)result[0];system.debug(accs);
Example of  SOSLApex classPublic with sharing class SOSLdemoExample{Public List optyList {get;set;}Public List conList{get;set;}Public List accList{get;set;}Public String searchStr{get;set;}Public SOSLdemoExample(){}Public void soslSearchmethod (){optyList = New List();conList = New List();accList = New List();
if(searchStr.length() > 2){String searchStr1 = '*'+searchStr+'*';String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS 

RETURNING  Account
(Id,Name,type),Contact(name,email),Opportunity(name,StageName)';
List> searchList = search.query(searchQuery);
accList = ((List)searchList[0]);
conList  = ((List)searchList[1]);
optyList = ((List)searchList[2]);if(accList.size() == 0 && conList.size() == 0 && optyList.size() == 0){apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sory, no results returned with matching string..'));return;}}else
{apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least three characters..'));return;}}}
Visualforce Page
5.New Features in SOQL:
a)“USING SCOPE” Query String:We can implement the "USING SCOPE" clause for Returning Records that selected in scope. It offers Query filtering, that which offer you certain limit Result with Filter Scope.b)Location Depended on SOQL Queries:You can implement location and Distance variables, in binding the expressions that give you Reference Apex Variables in SOQL and SOSL queries that referred by a colon (:).These are the best-known facts about SOQL, in upcoming blogs, we will update more data on this topic. Go through our blog Salesforce Future trends to get more updates on it.