You need to sign in to do that
Don't have an account?

Trigger After Delete not updating
I'm trying to update a field on the account when a child record is deleted but the field isn't updating. Here's the trigger:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) { // Make a list of the deleted subscription rate plans List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id, Name, Zuora__Account__r.Local_Listings__c, Zuora__Account__r.Engage__c, Zuora__Account__r.SEO__c, Zuora__Account__r.Social_Ads__c, Zuora__Account__r.Social_Posting__c, Zuora__Account__r.Website_Product__c Zuora__SubscriptionRatePlan__c IN :Trigger.old]; List<Zuora__SubscriptionRatePlan__c> newRatePlan = new List<Zuora__SubscriptionRatePlan__c>(); for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) { // Get Trigger.new version of the rate plan Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id); // Local Listings if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) { subInTriggerNew.Zuora__Account__r.Local_Listings__c = false; } // Engage if (sub.Name.contains('Engage')) { subInTriggerNew.Zuora__Account__r.Engage__c = false; } // Reviews if (sub.Name.contains('Review')) { subInTriggerNew.Zuora__Account__r.Reviews__c = false; } // SEO if (sub.Name.contains('SEO')) { subInTriggerNew.Zuora__Account__r.SEO__c = false; } // Social Ads if (sub.Name.contains('Social Ads')) { subInTriggerNew.Zuora__Account__r.Social_Ads__c = false; } // Social Posting if (sub.Name.contains('Social Posting')) { subInTriggerNew.Zuora__Account__r.Social_Posting__c = false; } // Website if (sub.Name.contains('Website')) { subInTriggerNew.Zuora__Account__r.Website_Product__c = false; } newRatePlan.add(subInTriggerNew); } update newRatePlan; }I appreciate any help I can get.
I believe that Trigger.newMap does not work in delete triggers. Try replacing that with Trigger.oldMap and let me know how that goes.
Kind Regards,
Jay
I expected to see a Lookup or Master Detail field called Zuora__Account__c linking Zuora__SubscriptionRatePlan__c to the Account.
See updated test class below