sosl salesforce example

SOSL is a select query that returns list of lists. That is, it can return list of multiple objects. It searches a parameter within fields fo multiple objects as specified in the query.
In the below example string 'test' is being searched in 4 objects Opportunity,account,Lead and contact. You need to specify in which fields it should search this string.
For example, if you want it to search in name and description fields of account then it would look like  account( name,description)
The list of lists has list of objects in the order mentioned in the query. For example if you specify account as first object in query; then the account list will be available at 0th location of list of lists.
visualforce page

Controller




As of now the SOSL can return only 2000 records (Combined for all the objects that are queried in the SOSL query) thsi is as per governer's limit.

9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi Yoganand, This is very nice!. Your post is really helpful for me as I am not familiar with search concepts. But will this search only among the objects which have tabs created in the application? Because I couldn't bring the search results of other objects available under the same application where the corresponding tabs are not included in the search page?.

    Please give your thoughts on this.

    I need to search among almost 60 custom objects and should bring the search results similar to our standard search. We have developed a custom site where we don't have option to bring the standard search functionality. So we are developing a custom search.

    ReplyDelete
  4. A very very helpful..Tanks a lot..please keep on posting articles.....Hearty thanks to u

    ReplyDelete
  5. How we use Pagging functionality Using sosl..Please Let Me Know If Any Solution

    ReplyDelete
  6. yogesh, for pagination use standard set controller, wherein you have to use soql. If you want to use sosl, you will have to build your own custom pagination logic

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. A very very helpful..Tanks a lot..please keep on posting articles.....Thanks a lot

    ReplyDelete
  9. A very very helpful..Tanks a lot..please keep on posting articles..... thanks alot to u

    ReplyDelete