You need to sign in to do that
Don't have an account?
Not able to execute the SOSL query
Hi
I am trying to execute the SOSL query with in Developer Edition of SalesForce.
This is my 3rd post still it is not answered.
Here is the code I am trying to execute
try
{
List<List<SObject>> searchList = [FIND 'Levis' IN NAME FIELDS RETURNING Opportunity(Amount, CloseDate, Name, OwnerId, StageName) LIMIT 1];
Opportunity[] records = (List<Opportunity>)searchList[0];System.debug('@@@@@ In the test1SOSL.....'+records.size());
Opportunity opp = [select id from Opportunity where name = 'Levis' limit 1];System.debug('##### Opportunity ID is.....'+opp.id);
}catch (Exception ex) {
System.debug(ex);
}
I am able to execute the SOQL query but when executing the SOSL query I get the size of the List as 0.
please tell me why it is happening with SOSL and help me go forward
regards
Sunil
Is this code in a testmethod?
If yes:
To ensure that test methods always behave in a predictable way, any Salesforce Object Search Language (SOSL) query that
is added to an Apex test method returns an empty set of search results when the test method executes. If you do not want the
query to return an empty list of results, you can use the Test.setFixedSearchResults system method to define a list ofrecord IDs that are returned by the search. All SOSL queries that take place later in the test method return the list of record
IDs that were specified by the Test.setFixedSearchResults method.