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

Trigger not updating field
I'm trying to mark a checkbox as false on the account when a child record is deleted but the field isn't updating. Here's my code:
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 WHERE Id IN :Trigger.old]; 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; } } }Sorry, I'm new to working with deleted records and not sure what I'm missing. Thanks in advance for your help!
It just lacks a new collection and an update.
Before the loop: List<Zuora__SubscriptionRatePlan__c> newRatePlan = new List<Zuora__SubscriptionRatePlan__c>();
End of the loop (inside): newRatePlan.add(subInTriggerNew);
After the loop: update newRatePlan;