Activity Forums Salesforce Questions and Answers SOSL Statements In Salesforce Apex

  • SOSL Statements In Salesforce Apex

  • Prachi

    Member
    September 19, 2018 at 1:23 pm

    What are  SOSL Statements In Salesforce Apex? explain with example

  • Parul

    Member
    September 19, 2018 at 1:28 pm

    Hi

    SOSL Statements
    SOSL statements evaluate to a list of lists of sObjects, where each list contains the search results for a particular sObject type. The result lists are always returned in the same order as they were specified in the SOSL query. If a SOSL query does not return any records for a specified sObject type, the search results include an empty list for that sObject.

    For example, you can return a list of accounts, contacts, opportunities, and leads that begin with the phrase map:

    List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];

    Hope this will help you.

    THANKS

  • chanchal kumar

    Member
    September 19, 2018 at 1:30 pm

    Hi,

    SOSL statement evaluate to a list of sobjects , where each list contains the search results for a particular sobject type, The result lists are always returned in the same order as they were specified in the query.
    If a SOSL query does not return any records for a specified sObject type , the search results include an empty list for that sObject.

    for example, you can return a list of accounts, contacts, opportunities and leds that begin with the phase map.

    List < list < subject >> search list = [ find 'map*' In ALL FIELDS RETURNING Account (ID, Name), contact, opportunity, lead ];
    Note : The syntax of the classon Apex differs from the syntax of the FIND clause in the SOAP API.
    In Apex, the value of the FIND cause is demarcated with single quotes.

    Example:

    FIND 'map*' IN ALL FIELDS RETURNING account (Id, Name], Contact, Opportunity, Lead.
    In the Force.com API, the value of the FIND Clause is demarcated with braces.

  • shariq

    Member
    September 19, 2018 at 1:30 pm

    Hi,

    Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records. Use SOSL to search fields across multiple standard and custom object records in Salesforce. SOSL is similar to Apache Lucene.
    Adding SOSL queries to Apex is simple—you can embed SOSL queries directly in your Apex code. When SOSL is embedded in Apex, it is referred to as inline SOSL.

    This is an example of a SOSL query that searches for accounts and contacts that have any fields with the word 'SFDC'.

    List<List<SObject>> searchList = [FIND 'SFDC' IN ALL FIELDS
    RETURNING Account(Name), Contact(FirstName,LastName)];

    Thanks

Viewing 1 - 4 of 4 posts

Log in to reply.

Original Post
0 of 0 posts June 2018
Now