I am getting NULL POINT Exception error when running my unit tests and can't seem to figure out how to go about this one.
This is the error Message;
|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountHttpCallout: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
It seems the error is being caused by this line
Account oldAcc = Trigger.oldMap.get(a.Id);
trigger AccountHttpCallout on Account (after insert, after update) {
//URL should be {CommandType}/{SalesforceId}/{LastModifiedUser}
if(!CallFutureCallOnce.b){
CallFutureCallOnce.recursiveHelper(true);
for (Account a : Trigger.new) {
Account oldAcc = Trigger.oldMap.get(a.Id);
String SalesforceId = a.id;
String LastModifiedUser = a.LastModifiedById;
if(a.LastModifiedbyId != '00540000001uezb')
if (trigger.new.size()>1){
return;
}
else{
//Send Call on Account Team Update
system.debug('oldAcc======>>'+oldAcc);
if(oldAcc != null && Trigger.isUpdate ){
if(a.RecordTypeID == Utilities.ProspectAccount && a.Type == 'Client'){
if( a.Client_Services_Director__c != oldAcc.Client_Services_Director__c ||
a.ASM__c != oldAcc.ASM__c ||
a.Onboarding_Manager__c != oldAcc.Onboarding_Manager__c ||
a.Compliance_Manager__c != oldAcc.Compliance_Manager__c ||
a.Owner != oldAcc.Owner ) {
String DMLAction = 'UpdateAccountTeam';
HttpCallOutGlobalClass.sendNotification(DMLAction, SalesforceId, LastModifiedUser);
}
}
//Send Call on all other updates
if(a.RecordTypeID == Utilities.ProspectAccount && a.Type == 'Client'){
if( a.Client_Services_Director__c == oldAcc.Client_Services_Director__c ||
a.ASM__c == oldAcc.ASM__c ||
a.Onboarding_Manager__c == oldAcc.Onboarding_Manager__c ||
a.Compliance_Manager__c == oldAcc.Compliance_Manager__c ||
a.Owner == oldAcc.Owner ) {
String DMLAction = 'SalesforceAccountModified';
HttpCallOutGlobalClass.sendNotification(DMLAction, SalesforceId, LastModifiedUser);
}
}
}
}
}
}
}