+ 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.

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!