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
O2O SimonO2O Simon 

Error when create opportunity with custom field

I have create a custom field called "Opportunity_Referral" at Opportunity.
When I create a apex class like :

Opportunity opportunity1 = new Opportunity(StageName='Proposal', Name='TempOppName', CloseDate=system.today(), OpportunityReferral='WEB');
insert opportunity1; 

It will have an error :
Error: Compile Error: Invalid field Opportunity_Referral for SObject Opportunity at line 3 column 139 

Can anyone help me to solve this? Thank you very much.

Simon
krisckrisc
If its a custom field, dont you have to add "__c" onto the end of the fieldname?
O2O SimonO2O Simon
It works! Thank you very much!
 
Simon