You need to sign in to do that
Don't have an account?
Ramesh Varatharaj
trigger for annual contract value
Hello experts, I need your help on a trigger. I have a requirement to calcualte the annual contract value for opportunities, this should be at both product level and at opportunity level. To be exact, i need to sum the first 12 months Revenue from productlineitemschedule at each productlineitem and then a total one at opportunity level. Could you please help with a sample code which could manage bulk record updates please.
All Answers
trigger ACVvalues on Opportunitylineitem (before update) {
map<ID, double> mapamount = new map<ID, double>();
// ACV
for(AggregateResult ar : [Select Sum(Revenue) numRecs, opportunitylineitemid OppId From opportunitylineitemschedule
Where opportunitylineitemid in :trigger.newmap.keyset() group by opportunitylineitemid ])
{
mapamount.put((ID)ar.get('OppId'), (Double)ar.get('numRecs'));
}
for(opportunitylineitem opp : trigger.new)
{
Opp.Acv__c = mapamount.get(opp.id);
}
}