You need to sign in to do that
Don't have an account?
XIO
Help with running Trigger on a specific Record Type
Hello,
I need the trigger below to only run for a specific opportunity record type called 'Conference'. Any assistance is greatly appreciated.
I need the trigger below to only run for a specific opportunity record type called 'Conference'. Any assistance is greatly appreciated.
trigger UpdateOpportunityProduct on Opportunity (before insert, before update ){ Map<String, Opportunity> discCodeToOppMap = new Map<String, Opportunity>(); for(Opportunity opp:Trigger.new){ discCodeToOppMap.put(opp.Discount_Code__c, opp); } List<Product2> prodLst = [SELECT ID, ProductCode FROM Product2 where ProductCode in :discCodeToOppMap.keySet()]; for(Product2 prod : prodLst){ discCodeToOppMap.get(prod.ProductCode).Discount_Code_LU__c = prod.ID; } }
Please fetch the record type and compare it with the opportunity record. I have updated the code below: Thanks,
Abhishek Bansal.