You need to sign in to do that
Don't have an account?

opportunity list update
I am having one list opportunity having one record -(Opportunity:{Id=0060l000004aCkfAAE, Name=Test 12112230 Test asddwd0, StageName=New}
and I want to update the stage name of the opportunity and another field too with the same id .what can I do?
I Tried the below but it is throwing error duplicate id-
opportunity opp1 = new Opportunity();
opp1.MembershipID__c='1234';
opp1.StageName='Quoted';
opp1.Id=oppList[0].id;
oppList1.add(opp1);
oppList.addall(oppList1);
and I want to update the stage name of the opportunity and another field too with the same id .what can I do?
I Tried the below but it is throwing error duplicate id-
opportunity opp1 = new Opportunity();
opp1.MembershipID__c='1234';
opp1.StageName='Quoted';
opp1.Id=oppList[0].id;
oppList1.add(opp1);
oppList.addall(oppList1);
Try this code. I did this code in three types try the which you want to do as shown below:
Type( According to Your Requirements):
1) If you want to update the single record of Opportunity(fields) without List.
2) If you want to update the single record of Opportunity(fields) with List.
3) If you want to update multiple records of Opportunity(fields) with List.
Your mistake in the code was you override the id of opportunity. In salesforce when we insert any records than automatically salesforce gives its uniques id.
Please Mark the best answer if this code helps you.
Thank You