I have a trigger to create a new Opportunity when a field on my Custom Object is changed, but it doesn't seem to be creating the new Opp. There are no errors, the new Opp is simply not created. I realize that it should only fire after update and not on insert.... What am I missing?
trigger MDwinning on MD_Meeting__c (after update) {
List <Opportunity> oppToInsert = new List <Opportunity> ();
for (MD_Meeting__c m : Trigger.new) {
if (m.SD_Action__c=='Sales Accepted Lead') {
Opportunity o = new Opportunity ();
o.OwnerId = m.Sales_Director__c;
o.Name = m.Name;
o.Market_Developer__c = m.Market_Developer__c;
o.AccountId = m.Account__c;
o.Type = 'Sales - New Business';
o.CloseDate = System.Today()+150;
o.MeetingLookup__c = m.Id;
oppToInsert.add(o);
}//end if
}//end for o
try {
insert oppToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
insert oppToInsert;
at the end of the trigger.