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
devcg15devcg15 

How do I access the standard and custom both fields of a standard object with a standard controller?

Hi,
I am working on standard objects in which I want to fetch all fields (standard and custom both) dynamically in a list.
For custom fields can fetch from the dynamic list but doesn't get custom field’s value.
 
for(SObject feedObject: sobjs){
     if(feedObject instanceOf Lead){
          Lead_Title = ((Lead)feedObject).Title; 
          Lead_Company = ((Lead)feedObject).Company;
          Lead_TestField= ((Lead)feedObject).TestField__C;    //  doesn’t  get the value of ” TestField “.
       }
}
 
sfdcMonkey.comsfdcMonkey.com
hi Indranial Deria 
i debug your code my code working wel,l i featch custom filed as well please check your sobjs var list ,that you query TestFiled__c feild from lead
my sample code is here...
List<lead> sobjs =  [select id, Title,company,SICCode__c from lead where id ='00Q2800000MhEmI' ] ; 

for(SObject feedObject: sobjs){
   
          system.debug(((Lead)feedObject).Title); 
          system.debug(((Lead)feedObject).Company);
          system.debug(((Lead)feedObject).SICCode__c);   // custom field 
         	
       
}

User-added image

debug log -:
User-added image
thanks 
 Please mark it as solved if this helps you so that it will make for others as a proper solution ;)