You need to sign in to do that
Don't have an account?
Scott Landes
How to pull in fields from record in Apex Trigger
I'm trying to figure out how to create an Apex trigger that fires different classes depending on the Opportunity Type. I added what I thought would work below, but it doesn't seem to be pulling the fields like I thought it would. Can someone show me how to pull in values from the updated record? Any help is greatly appreciated as I'm trying to get this fixed as soon as possible.
trigger OrderRollupSummaryTrigger on Order_Location_Package__c (after insert, after update, after delete, after undelete) { if (Order_Location_Package__c.Order_Sheet__c.Opportunity__c.Type = 'NEW' || Order_Location_Package__c.Order_Sheet__c.Opportunity__c.Type = 'Renewal') { if (trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isUndelete)) { OrderLocationRollupSummary.rollupOrderPackages(trigger.new); } else if (trigger.isAfter && trigger.isDelete) { OrderLocationRollupSummary.rollupOrderPackages(trigger.old); } } else if (Order_Location_Package__c.Order_Sheet__c.Opportunity__c.Type != 'NEW' || Order_Location_Package__c.Order_Sheet__c.Opportunity__c.Type != 'Renewal') { if (trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isUndelete)) { OrderLocationRollupSummaryOther.rollupOrderPackages(trigger.new); } else if (trigger.isAfter && trigger.isDelete) { OrderLocationRollupSummaryOther.rollupOrderPackages(trigger.old); } } }
Thanks!
After quite a lot of reading, I found the best way to do this. Specifically with a formula field (to avoid SOQL queries in the trigger)