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
jagdish nikam 9jagdish nikam 9 

Access Custom field in SOQL query

Hi All,

Could you please tell me how can I access custom field in SOQL query? 

I have custom field amount in standerd object contact and i have written SOQL query List<contact> acc = [select Id, name, amount__c from contact]; but it doesn't work. 

Please help!!!
hi jagdish nikam
your query is look good , for access custom fields we are use __c after field name so
what error you are getting ?
* make sure you have data in amount field
* make sure give permission to custom field
Ajay K DubediAjay K Dubedi
 Hi jagdish,
 I used amount__c as a currency field and it's work perfectly for me.
 Try this :  
List<contact> acc = [select Id, name, amount__c from contact where amount__c > 0];
for(contact c : acc)
    System.debug('ID : '' Name :  '' Amount : '+c.amount__c );