0

I am getting error while querying Account & cusst obj Customer ,Below is my error and query.

Error :"Line: 9, Column: 29 Incompatible types since an instance of List<SObject> is never an instance of List<Account>"

List<List<SObject>> custAcctSearchList=new List<List<SObject>>();
//SOSL query which will search for Text 'ABC'string in Customer & Account
//object fields
custAcctSearchList=[FIND 'ABC*' IN ALL FIELDS RETURNING Apex_Customer__c(Id,Apex_Customer__c.Name,
                     Apex_Customer__c.Apex_Customer_Description__c),Account(Id,Name)];    

system.debug('Result for Acct & cust '+custAcctSearchList);
Apex_Customer__c[] searchedCustomer =((List<Apex_Customer__c>)custAcctSearchList[0]);
Account[] searchedAccount =((List<Account>)custAcctSearchList[1]);

system.debug('Result of Customer List '+searchedCustomer);
system.debug('Result of Customer List '+searchedAccount);
    
  • The code looks fine to me. Can you share the complete error message that you are getting. Basically the name of the sobject for both the lists. – Aakriti.G Jul 10 at 9:51
  • what I posted is entire error msg . sObject name- Apex_Customer__c & other is Account(standard obj) – AM_SFDC Jul 11 at 5:55
  • do you have a class named Account declared somewhere else in your code? – cropredy Jul 13 at 4:29
  • No ! I have not defined any class named Account – AM_SFDC Jul 14 at 4:50

Your Answer

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

Browse other questions tagged or ask your own question.