+ Start a Discussion
Ram ChaturvediRam Chaturvedi 

How can we access List<sObject> type object value in for each loop .?

List<sObject> objs ;
objs = Database.query('select name from Account');

                for(sObject sobj : objs){

                          system.debug(sobj['name']);           // this gives error Expression must be a list type: SObject

Any reason you want to go for sobject instead of list<Account>?
Hi Ram Chaturvedi,

Try this in your system debug.

Then you can able to access each record.



Ram ChaturvediRam Chaturvedi
 yes rohit , Actually i am creating custom lookup , for objects , so on object selection i am showing popup and showing object related record .

Ram ChaturvediRam Chaturvedi
Thanks anil