Friday, June 1, 2012

Dynamic SOSL


Dynamic SOSL (Sales force Object Search Language) refers to the creation of a SOSL string at runtime with an Apex script. Dynamic SOSL enables you to create more flexible applications which are most beneficial in sales force.
For example, you can create a search based on input from an end user, or update records with varying field names. To create a dynamic SOSL query at runtime, use the search query method.
Dynamic SOSL e.g:
List> mySOSLQuery = search. query (SOSL_search_string);
The following example exercises a simple SOSL query string.
String searchqueryString='FIND\'Edge*\'IN ALL FIELDS RETURNING
Account (id, name, address), Contact, Lead';
List>searchList=search.query(searchqueryString);
Description:
Dynamic SOSL statements evaluate to a list of lists of salesforce Objects, where each list contains the search results for a particular sObject types.
The result lists are always returned in the same order as they were specified in the dynamic SOSL query. From the example above, the results from Account are first, then Contact, then Lead.

No comments:

Post a Comment