function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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

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

Try this in your system debug.

 system.debug(sobj.get('name'));    
Then you can able to access each record.

Thanks
Anil.B  

             


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