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
Vishnu_SFDCVishnu_SFDC 

Retrieve Data from a field using string.

Hello All,

I have the Api name of a field in string format. How can i retrieve the data from that field using that string. For example, 
On Lead object i ahave a field called Points__c.
Now in apex code i have somthing like this. String field = 'Points__c';

From this how can i get the value of lead.Points__c?

Thanks in advance.
Best Answer chosen by Vishnu_SFDC
BalajiRanganathanBalajiRanganathan

it is easy.  lead.get('Points__c');

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm#apex_System_SObject_get