You need to sign in to do that
Don't have an account?
SOSL - Find - problem reading results
Hi,
I read SOSL documentation & examples, although I can't seem to read the results I get from "Find" query.
When I run the following code, I can see in the debug that it found 21 results.
List<List<SObject>> searchList = [Find 'Ja*' RETURNING candidate__c];
When I try to read them I get an empty "Candidate__c" list:
if(searchList != null){
Candidate__c []cands = (List<Candidate__c>)searchList[0];
for(Candidate__c c : cands){
System.debug('Found Id '+c.Id);
}
}
If I try to use SOQL - select, I can see the results.
Should I set special flags in-order to use SOSL?
Appreciate any help!
Uri
Found the solution, it seems that for custom objects (under managed package) I should add namespace before.
So for my example I should simply placed:
skills__Candidates__c
instead of
Candidates__c
See this post:
http://boards.developerforce.com/t5/Apex-Code-Development/SOSL-finding-but-not-returning-rows-for-custom-objects/m-p/149947#M20972
Thanks for your help!
Uri
All Answers
This:
gave me these results in the debug log....
20:01:34:142 USER_DEBUG [3]|DEBUG|(FSA__c:{Id=a0MJ0000000E039MAC})
Yours looks fine, can you post the debug log?
U can interate the result in for loop and print it.
In all these ways u can retrieve the result.
I didn't got of what you said about special flags in-order to use SOSL. can you say it clearly.
When executing the "Find" query the debug logs outputs:
15:05:26.118 (118279000)|SYSTEM_METHOD_EXIT|[32]|System.debug(ANY)
15:05:26.118 (118371000)|SOSL_EXECUTE_BEGIN|[35]|Find 'Ja*' RETURNING candidate__c,jobposition__c
15:05:26.130 (130221000)|SOSL_EXECUTE_END|[35]|Rows:21
When traversing the results I get empty list:
15:05:26.130 (130301000)|USER_DEBUG|[37]|DEBUG|In [searchTags] Selected Tag Records ==> (())
15:05:26.130 (130310000)|SYSTEM_METHOD_EXIT|[37]|System.debug(ANY)
15:05:26.130 (130319000)|SYSTEM_METHOD_ENTRY|[38]|System.debug(ANY)
15:05:26.130 (130332000)|USER_DEBUG|[38]|DEBUG|In [searchTags] Selected Tag Records ==> ()
Thanks!
Uri
I just tried running the same "Find" query on Standard Object "Event" and I could read the results successfully.
When I apply a similar "Find" on a custom object "Candidate__c" from some reason I can not get the results.
Maybe it is a configuration issue?
Found the solution, it seems that for custom objects (under managed package) I should add namespace before.
So for my example I should simply placed:
skills__Candidates__c
instead of
Candidates__c
See this post:
http://boards.developerforce.com/t5/Apex-Code-Development/SOSL-finding-but-not-returning-rows-for-custom-objects/m-p/149947#M20972
Thanks for your help!
Uri