You need to sign in to do that
Don't have an account?
Darrell Gallegos
Can Anybody Offer Insight to this Covering this Trigger 100%
I am having a problem completing the Test Class for the following Trigger. My current class has 90% code coverage however, the bold text below is the line I cannot gain coverage for. Can anybody lead me in the right direction?
Thank you for any clues.
Struggling with Line 22.
Thank you for any clues.
trigger UKCheck on Domain__c (before insert, before update) { Map<String,Country_Codes__c> getCodes = Country_Codes__c.getAll(); for (Domain__c dom : Trigger.new) { if(dom.Country__c != NULL) { for(String s : getCodes.keySet()) { if(s.containsIgnoreCase(dom.Country__c)) { dom.UK_Team_Checkbox__c = TRUE; } } } if(Trigger.isUpdate) { if (Trigger.oldMap.get(dom.Id).Company__c != Trigger.newMap.get(dom.Id).Company__c) { if(dom.Company__c != NULL) { if(dom.Company__r.OwnerId != NULL) { dom.OwnerId = dom.Company__r.OwnerId; System.debug(dom.Owner); System.debug(dom.Company__r.Owner.Id); System.debug(dom.Company__c); } } } } } }
Struggling with Line 22.
Make your trigger run on 'after update' instead of before update. On before update ownerid is not visible in apex trigger, therefore its not covering the highlighted line.
Please like then answer and mark it as best if this helps.
Thanks,
Aman
Hi Darrell,
Can you please send your Test class code here: So we can just some edits in your code if there is need anything.
Regards,
Suraj
I will create a test User to complete this as opposed to hard coding Record ID, but I am concerned with not meeting the 100% coverage right now.
Let us know if this will help you