+ Start a Discussion
Arun Rote 3Arun Rote 3 

How to retrieve sobject from List<SObject>

I have method which returns  static List<SObject> . How can i retrieve retruned sobject.

 
Best Answer chosen by Arun Rote 3
WEN JIEWEN JIE
Hi Arun,

FYI. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm?search_text=LIST
 
List<Account> accList = new List<Account>();
accList = [select id, name from Account where name like '%a%'];

for(Account acc :  accList){
    system.debug('======Account' Name======' + acc.name);
}

 

All Answers

WEN JIEWEN JIE
Hi Arun,

You could traverse your return list.

Thanks.
Arun Rote 3Arun Rote 3
Wen,
Thanks for your quick response.Do you have any sample code.

Thanks,
 
WEN JIEWEN JIE
Hi Arun,

FYI. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm?search_text=LIST
 
List<Account> accList = new List<Account>();
accList = [select id, name from Account where name like '%a%'];

for(Account acc :  accList){
    system.debug('======Account' Name======' + acc.name);
}

 
This was selected as the best answer
Arun Rote 3Arun Rote 3
Thanks.