Please, Help. The trigger fires only for the first opportunity created and for editing. When creating subsequent opportunities, the trigger does not fire.
We need to support gift cards which allows users to reduce Opportunity price on fixed amount. If the name of the card matches the entered one and it is active, then we make a discount
What should I add?
trigger GiftCardStatusForOpprtn on Opportunity (before insert, before update) {
List<Gift_Card__c> gitfCardList = [SELECT Name, Active__c, Amount__c
FROM Gift_Card__c];
Decimal amountResult;
for(Opportunity op : Trigger.New) {
for(Gift_Card__c gc : gitfCardList){
if(op.Gift_Card_Name__c == gc.Name){
if(gc.Active__c == true){
amountResult = op.Amount - gc.Amount__c;
op.Amount = amountResult;
}
}
}
}
}