You need to sign in to do that
Don't have an account?
Christine_K
Code Coverage for Trigger.IsDelete
I was hoping to get some assistance with code coverage for a particular class.
In my trigger I have:
I can't seem to get code coverage for the above. Any assistance would be greatly appreciated.
Thanks!
In my trigger I have:
else if(Trigger.isDelete) { handler.clearAccountEmails(Trigger.old, Trigger.new, Trigger.oldMap); }Trigger Handler:
public void clearAccountEmails(Contact[] oldContacts, Contact[] updatedContacts, Map<ID, Contact> oldContactsMap) { List<Account> accounts = new List<Account>(); for(Contact c : oldContacts) { if(c.AccountId != null && c.Primary_Contact__c) { Account a = new Account(id = c.AccountId); if(c.Email != null) a.Primary_Contact_Email_1__c = ''; if(c.Email != null) a.Customer_Email__c = ''; if(c.Email_2__c != null) a.Primary_Contact_Email_2__c = ''; if(c.Servicing_Contact_Method__c != null) a.Servicing_Contact_Method__c = ''; accounts.add(a); } } if(!accounts.isEmpty()) { try{ update accounts; } catch(exception e){ System.debug('The following exception has occurred: ' + e.getMessage()); } system.debug(accounts); }
I can't seem to get code coverage for the above. Any assistance would be greatly appreciated.
Thanks!
Raj Vakati
Try some think below
Christine_K
That's what I did for my first attempt at obtaining code coverage for the IsDelete, but that doesn't seem to do the trick. Lines still come back in red.
Raj Vakati
Can you share the complete trigger?
Christine_K
Christine_K
I just moved the Trigger.IsDelete above the isAfter and that resolved the issue.