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

Trigger to fire on Before Delete
Hi All,
I am having below trigger which calls a method "sendNotification" when the account name is changed. I want this trigger to call the method when the account is deleted ie)on before delete operation. Please help me on how this can be done.
Abraham
I am having below trigger which calls a method "sendNotification" when the account name is changed. I want this trigger to call the method when the account is deleted ie)on before delete operation. Please help me on how this can be done.
trigger Contactcallout2 on Account(after update) { List<Contact> ListContact = new List<Contact>(); Set<ID> acctIds = new set<ID>(); for(Account acct : trigger.new) { if(Trigger.oldMap.get(acct.id).Name != acct.Name){ acctIds.add(acct.Id); } } if(acctIds.size() > 0){ for(Contact con : [SELECT id,Email,FirstName,LastName,phone,Title__c,Account.Name,status__c, AccountId FROM Contact WHERE AccountId IN : acctIds AND RecordTypeid = '012D6765454BaFA']){ WebServiceCallout.sendNotification(con.Id,con.Email,con.FirstName,con.LastName,con.phone,con.Title__c,con.Account.Name,con.status__c); } } }Many Thanks in advance
Abraham
All Answers
Thank you soo much for the quick help and response.
i tried the above code it compiles successfully but i get below error on deleting an account
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger Contactcallout2 caused an unexpected exception, contact your administrator: Contactcallout2: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Contactcallout2: line 8, column 1".
Many Thanks in advance
Abraham
Thanks