0
list<list<sObject>> Mylist = New list<list<sObject>>();
Mylist = [ FIND {IBM} IN ALL FIELDS RETURNING Account(name),Lead(name)];
System.debug(Mylist);

enter image description here

  • Why bother with the "new List<List<SObject>>()" assignment when you immediately re-assign the value of MyList anyway? I see so many people doing this for absolutely no good reason. – Phil W Apr 12 at 8:36
1

The {IBM} is confusing the compiler as curly brackets are very significant in the language.

This will compile:

Mylist = [ FIND 'IBM' IN ALL FIELDS RETURNING Account(name),Lead(name)];

or if you want the search term to vary:

String searchTerm = 'IBM';
Mylist = [ FIND :searchTerm IN ALL FIELDS RETURNING Account(name),Lead(name)];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.