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

Attempt to de-reference a null object:
I am able to save the trigger but getting the following error while creating / editing the record...
System.NullPointerException: Attempt to de-reference a null object: Trigger.ComplTrigger: line 34, column 1
see my trigger below..
trigger ComplTrigger on Complaint_Inquiries__c (before insert, before update) { Set<id> AccIds = new Set<id>(); for (Complaint_Inquiries__c c : Trigger.new) AccIds.add(c.Account__c); Map<id, Account> AccIDmap = new Map<id, Account>([Select Name, BillingStreet,BillingCity, BillingState, BillingPostalCode from Account Where Id in :AccIds]); for (Complaint_Inquiries__c Compl : Trigger.new){ if(Compl.Copy_From_Account__c == true){ Compl.Business_Name__c = AccIDmap.get(Compl.Account__c).Name; Compl.Business_Address__c = AccIDmap.get(Compl.Account__c).BillingStreet; Compl.Business_City__c = AccIDmap.get(Compl.Account__c).BillingCity; Compl.Business_State__c = AccIDmap.get(Compl.Account__c).BillingState; Compl.Business_Zip__c = AccIDmap.get(Compl.Account__c).BillingPostalCode; Compl.Copy_From_Account__c = false; } } Set<id> ContIds = new Set<id>(); for (Complaint_Inquiries__c c : Trigger.new) ContIds.add(c.Contact__c); Map<id, Contact> ContIDmap = new Map<id, Contact>([Select FirstName from Contact Where Id in :ContIds]); for (Complaint_Inquiries__c Compl : Trigger.new){ if(Compl.Copy_From_Contact__c == true){ Compl.Business_Contact_First_Name__c = ContIDmap.get(Compl.Contact__c).FirstName; Compl.Copy_From_Contact__c = false; } } }
Please help
Looks like you are pulling a null from ContIDmap. When it tries to get FirstName on null contact the error is thrown. You could probably by pass it with a null check :
Is Contact__c a required field on Complaint_Inquiries__c?
It's an optional but lookup and it is required in contact object.
Just for records without Contact__c filled out or all of them? If there is no contact reference in data there is no way to get the first name