Here's what I have.
Basically, if an opportunitylineitem is deleted, before it gets delete I need the probability field on opportunity to be set to 99. I can't seem to get it to work. What am I missing?
trigger BeforeDeleteProbability on OpportunityLineItem (before delete) {
Set<Id> oppIds = new Set<Id>();
for (OpportunityLineItem oli:trigger.old){
oppIds.add(oli.opportunityId);
}
Map<Id, Opportunity> oppstoUpdate = new Map<Id, Opportunity>([Select Id, probability From Opportunity where id in: oppids]);
for(OpportunityLineItem oli: Trigger.old){
oppstoUpdate.get(oli.OpportunityId).probability = 99;
}
try {
update oppsToUpdate.values();
}
catch(Exception Ex){
system.debug(Ex);
}
}