You need to sign in to do that
Don't have an account?
VF ERROR
Hi ,
I was using this particular code snippet specified below and it threw me an error (highlighted in red).. and I would also like that this code snippet works fine with other Standard and custom objects but not for Account......can some please help me out by educating me as to why this kind of an error occurs.
public with sharing class LookupPopupController
{
public String query {get; set;}
public List<Account> accounts {get; set;}
public PageReference runQuery()
{
List<List<Account>> searchResults=[FIND :query IN ALL FIELDS RETURNING Account (id, name, billingstreet, billingcity, billingpostalcode)];
accounts=searchResults[0];
return null;
}
}
Compile Error: Illegal assignment from LIST<LIST<SObject>> to LIST<LIST<Account>>
SOSL returns a list of sobject lists, but you have told the compiler that it is returning a list of account lists.
Its better practice to leave it returning the sobjects and cast the result when you assign to your account list. E.g.