You need to sign in to do that
Don't have an account?
Brooks Johnson 6
Help With a Null Pointer Error
Hi Friends,
I know null pointer errors are such a common question I hate to add another one. But I can't figure out what I am doing wrong and I am hoping I can learn something here. I'm getting the error from my final For Loop. I thought I had checked for it with the != null in my If statement. Hoping someone can point me in the right direction.
I know null pointer errors are such a common question I hate to add another one. But I can't figure out what I am doing wrong and I am hoping I can learn something here. I'm getting the error from my final For Loop. I thought I had checked for it with the != null in my If statement. Hoping someone can point me in the right direction.
public class UniqueEmailCountHandler { public static void uniqueRelationshipOwnerEmails(List<relationship_owner__c> roList){ //count the unique emails that have been sent by a relationship owner // add all contacts associated with relationship owner to map. Map<id, Contact> contactMap = new Map<Id, Contact>([SELECT Id, New_Relationship_Owner1__c FROM Contact WHERE New_Relationship_owner1__c IN : roList]); system.debug('Number of relationship owners in trigger = ' + roList.size()); system.debug('Contacts found = ' + contactMap.size()); //put tasks where whoId is in the contact map into a new map List<Task> taskList = [SELECT Id, WhoId,Subject FROM Task WHERE WhoId IN :contactMap.keySet() AND Subject LIKE '%Pardot List %']; system.debug('Tasks Found and added to map = ' + taskList.size()); //use set to dedupe the list Map<Id, Set<String>> subjectLineMap = new Map<Id, Set<String>>(); for(task t : taskList){ Id ownerId = contactMap.get(t.WhoId).New_Relationship_Owner1__c; if(!subjectLineMap.containsKey(ownerId)){ subjectLineMap.put(ownerId, new Set<String>()); system.debug('Subect Line found ' + t.Subject); } Set<String> subjects = subjectLineMap.get(OwnerId); subjects.add(t.Subject); subjectLineMap.put(OwnerId, Subjects); } system.debug('Map size =' + subjectLineMap.size()); system.debug('map values =' + subjectLineMap.values()); system.debug('map keys =' + subjectLineMap.Keyset()); { for(relationship_owner__c relationshipOwner : roList){ if(subjectLIneMap.get(relationshipOwner.Id).size() != Null){ relationshipOwner.Unique_Emails_Sent__c = subjectLIneMap.get(relationshipOwner.Id).size(); } }
All Answers