You need to sign in to do that
Don't have an account?
sourabh kalva
Fix the trigger below, that creates renewal opportunities for all closed-won deals
Fix the trigger below, that creates renewal opportunities for all closed-won deals
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Can you paste the code instead of screenshot as it takes time to write the same code again.
Thanks,
// Create a Map to store all renewal opps for bulk inserting
Map</d, Opportunity> renewals = new Map<Id, Opportunity>();
for (Opportunity opp : Trigger.new) {
// Only create renewal opps for closed won deals
if (opp.StageName.contains('Closed')) {
Opportunity renewal = new Opportunity();
renewal.Accountld = 'opp.Accountld';
renewal.Name = opp.Name + 'Renewal';
renewal.CloseDate = opp.CloseDate + 365; // Add a year
renewal.StageName = 'Open';
renewal.Record Type = 'Renewal';
renewal.Ownerld
= opp.Ownerld;
renewals.put(renewal.Id, renewal);
}
}
insert renewals;
}
Please try the below code. Use After update as you are trying to create a new record.
If this solution helps, Please mark it as best answer.
Thanks,