• #35300
     Prachi #6
    Forcetalks

    SOSL Statements In Salesforce Apex

    What are  SOSL Statements In Salesforce Apex? explain with example

    #35307
    Salesforce | Parul Parul #2
    Forcetalks

    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

    #35310
    Forcetalks

    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.

    #35311
    Salesforce | shariq shariq #1
    Forcetalks

    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 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?