Thursday 20 August 2015

Dynamically Binding Variable in SOSL Query Salesforce

          Use the Salesforce Object Search Language (SOSL) to search your organization’s Salesforce data for specific information. With SOSL, you can search all objects—including custom objects—that you have access to in a single query.

          The below example helpful to binding variable in a dynamic SOSL query. Apex script variables and expressions can be used if preceded by a colon (:).

  1. public class SOSLController
  2. {
  3.     public static void findMatchingData(String str)
  4.     {
  5.         List<List<Sobject>> searchResult = [FIND :str RETURNING Account, Lead];
  6.         System.debug(searchResult);
  7.     }
  8. }


Search Scope:
  • Any elements such as picklists that are defined as not searchable (searchable is false). To determine whether a given object is searchable, your application can invoke the describeSObjects() call on the object and inspect the searchable property in the DescribeSObjectResult.
  • It enable you to search text, email, and phone fields
  • Number, date, or checkbox fields are not allowed to search. To search for such information, use the query() call instead.
  • Textarea fields, unless you use the ALL FIELDS search group.
  • Attachment records associated with certain objects, such as Account, Contact, or Opportunity. Default scope is ALL FIELDS.

1 comment:

  1. Enjoyed reading the article above, really explains everything in detail, the article is very inter sting and effective. Thank you and good luck for the upcoming articles Oracle soa certification

    ReplyDelete

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...