我试图弄清楚如何创建一个 Apex 触发器,该触发器根据机会类型触发不同的类。我在下面添加了我认为会起作用的内容,但它似乎并没有像我想象的那样拉动这些领域。有人可以告诉我如何从更新的记录中提取值吗?非常感谢任何帮助,因为我正试图尽快解决这个问题。
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);
}
}
}
谢谢!