You need to sign in to do that
Don't have an account?
David Budimir
0% Code Cover Error for Account Trigger
Hey all,
I've been working with the below trigger. I've had no problem executing this in our current Sanbox enivorment (seemed to work fine), but I don't understand why theres no code coverge here at all. Does anything stand out as being obviously wrong?
Thanks in advance,
David
I've been working with the below trigger. I've had no problem executing this in our current Sanbox enivorment (seemed to work fine), but I don't understand why theres no code coverge here at all. Does anything stand out as being obviously wrong?
Thanks in advance,
David
trigger AccountAfter on Account (after insert, after update){ Set<Id> parentAccs = new Set<Id>{}; Map<Id, Integer> childCount = new Map<Id, Integer>{}; for (Account a : trigger.new) if(a.ParentId != null) parentAccs.add(a.ParentId); //collect parent ids for(Account acc : [Select Id, ParentId from Account where ParentId IN :parentAccs]){ if(childCount.get(acc.ParentId) == null) childCount.put(acc.ParentId, 0); //create a counter for parent childCount.put(acc.ParentId, childCount.get(acc.ParentId) +1); //increment counter } List<Account> accsUpdate = new List<Account>{}; for(Id accId : childCount.keySet()) accsUpdate.add(new Account(Id = accId, ChildCount__c = childCount.get(accId))); //set parent counts if(accsUpdate != null && !accsUpdate.isEmpty()) Database.update(accsUpdate); //update parent accounts }
Can you share your test class, so that we can identify the issue in better way.
Best Regards,
Mithun.
David i think you have not written any test class and just viewing default percentage or in other case your trigger is not active first active your trigger then test it using test class.
Best Regards
Iqrar Ahmed