function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SandeeshSandeesh 

SOSL query

Currently i want to find all the ConvertedOpportunityId's from Lead Object using SOSL query:-

 

String queryString;      

String searchdialog = 'New York'
queryString = 'FIND \''+searchdialog+'\' IN ALL FIELDS RETURNING Lead(ConvertedOpportunityId where isConverted = true)';

List<List<Lead>>resultset=search.query(queryString); 

 

But i am unable to get the rows.

Thanks in Advance,

Sandeesh

Ankit AroraAnkit Arora

Hope this will resolve your problem.

 

http://forceguru.blogspot.com/2011/01/inquery-behaviour-with-sosl.html

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

nasknask

@ ankit '

i just visted ur blog. where u had explined that the it searces in first 200 records? then what is the sol if i need to serch only one particluar record. ?

will it not be returned if its not with in 200 records?

So can you explain this.

Ankit AroraAnkit Arora

Hi,

 

I have just explained the native behavior of SOSL in salesforce. First 200 records for the SOSL is fetched out after that criteria is implemented on the results.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

nasknask

so if i want some partucular reocrd with some particular id then how should i frame my sosl then?

SandeeshSandeesh

In my case there are hardly 20 records..Still I m not getting the list of rows.

Ankit AroraAnkit Arora

That's strange, then you have to try the below options :

 

1) Use Databse.Execute instead of search.query

2) Try running your SOSL in system logs, does it return any results?

3) Use double quotes instead of single quotes -: queryString = 'FIND \"'+searchdialog+'\" IN ALL FIELDS RETURNING Lead(ConvertedOpportunityId where isConverted = true)';

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

bob_buzzardbob_buzzard

While your syntax is correct, you aren't getting any results as you are trying to access converted leads.  Once a lead is converted, according to the help it is no longer visible outside of reports.

 

I've tested this by creating two leads with 'Test' in the name and converting one of them.  When I run a SOSL search on this, I only get the unconverted lead in the search results.

SandeeshSandeesh

hey Bob,

 I am able to access the ConvertedOpportunityid(using Soql though) , which is a field of lead Object even after converting the particular Lead.

I wonder whether it works with SOSL ???

 

bob_buzzardbob_buzzard

You can access this fine via SOQL - converted leads aren't treated any differently.  SOSL excludes them as otherwise you could end up with lots of matches that aren't relevant as the leads were converted some time ago.