I have 2 triggers:
The first:
trigger AutoProduct on Opportunity (before insert,after insert) {
for(Opportunity newOppt : Trigger.new){
if ((trigger.isBefore)&&(Trigger.isInsert)){
// SET SOME FIELDS
}
opptsToInsert.add(newOppt);
if ((Trigger.isAfter)&&(Trigger.isInsert)){
//GET OPPORTUNITY
//CREATE OPPORTUNITY LINE ITEM FOR EACH NEW OPPORTUNITY
//CREATE OPPORTUNITY LINE ITEM QUANTITY AND REVENUE SCHEDULE FOR EACH NEW OPPORTUNITY PRODUCT
}
}
The second
trigger AutoProductupdate on Opportunity ( before update,after update) {
for(Opportunity newOppt : Trigger.new){
if (trigger.isAfter){
//DELETE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS
// UPDATE OPPORTUNITY LINE ITEM
// CREATE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS
}
}
}
The problem is that when i insert an opportunity(execution first trigger) it's also executed the second trigger on update.
I want that on creation of an opportunity is only executed the first trigger.
How can avoid this?
Thank in advantage for any advice.
BR.