You need to sign in to do that
Don't have an account?
Chidanand Magadum 24
Create New Opportunity
Hai All,
How to create new opportunity Using Apex Code. Any Code help Please.
How to create new opportunity Using Apex Code. Any Code help Please.
what the issue you are facing in that.
it is as simple as inserting any other object. first initialize Opportunity object and then call insert method.
if you have other fields then you can pass them as well with above call as
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
This is my Code.
Opportunity opp = new Opportunity();
opp.CloseDate=date.today().addMonths(2);
opp.Name='test opp1';
opp.StageName='Legal';
opp.AccountId='001J000001Z9p7o';
opp.Amount=50000;
update opp;
update last line with
it will work.
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
"Try this code to create opportunity record using apex code."
If you find your Solution then Mark this as Best Answer
Thank you!
Regards,
Suraj Tripathi