You need to sign in to do that
Don't have an account?
RAM R
I am facing dereference null , Can any one suggest me if knows ?
Hello,
I have 3 objects zipcode , address, contact.
---contact have one physical address & contact have firem channel
---address have one zipcode(text)
---zipcode have zip and territory channel
i am facing de reference null object please suggest me if any one knows and find below my code....
Public void populateZoneZipTerritory(List<Contact> contactList , Map<Id, Contact> contactOldMap){
set<Id> contId = new set<Id>();
set<string> zipcodeName = new set<string>();
set<string> firmChannel = new set<string>();
Map<string, Zip_Code__c> zipcodeMap = new Map<string, Zip_Code__c>();
Map<Id, Contact> contMap = new Map<Id, Contact>();
for(Contact c : contactList){
if((c.Firm_Channel__c != null)&&(c.Firm_Channel__c != contactOldMap.get(c.Id).Firm_Channel__c)){
contId.add(c.Id);
firmChannel.add(c.Firm_Channel__c);
contMap.put(c.Id, c);
system.debug('*******'+contMap);
}
}
List<Addresses__c> addressList = new List<Addresses__c>([select Id, Zip_Code__c, Contact__c, Address_Type__c from Addresses__c where Address_Type__c = 'Physical' and Contact__c IN :contId]);
for(Addresses__c a: addressList){
zipcodeName.add(a.Zip_Code__c);
}
List<Zip_Code__c> zipcodeList = new List<Zip_Code__c>([select Id,Name,Zone__c,Zone__r.Territory__c,Territory_Channel__c from Zip_Code__c where Name IN :zipcodeName and Territory_Channel__c IN :firmChannel]);
for(Zip_Code__c z :zipcodeList){
zipcodeMap.put(z.Name+''+z.Territory_Channel__c, z);
system.debug('******'+ zipcodeMap);
}
Map<Id, Zip_Code__c> conZipMap = new Map<Id, Zip_Code__c>();
for(Contact c: contactList){
for(Addresses__c a: addressList){
if(a.Contact__c == c.Id){
if(zipcodeMap.containsKey(string.valueOf(a.Zip_Code__c+''+c.Firm_Channel__c))){
conZipMap.put(a.Contact__c , zipcodeMap.get(a.Zip_Code__c+''+c.Firm_Channel__c));
system.debug('&&&&&' + conZipMap);
system.debug('&&&&&' + a.Zip_Code__c+''+c.Firm_Channel__c);--------------> // i got the value here
system.debug('^^^^^^^^'+conZipMap.containsKey(c.Zip_Code__c));
}
}
}
}
for(Contact c: contactList){
if(!conZipMap.containsKey(c.Zip_Code__c)){
if((c.Firm_Channel__c != null)&&(c.Firm_Channel__c != contactOldMap.get(c.Id).Firm_Channel__c)){
c.Zip_Code__c = conZipMap.get(c.Zip_Code__c).Id;------------------->// i need to update zipcode here
system.debug('&&&&&&&' + c.Zip_Code__c);
system.debug('&&&&&&&' + conZipMap.get(c.Zip_Code__c).Id);
}
}
}
}
I have 3 objects zipcode , address, contact.
---contact have one physical address & contact have firem channel
---address have one zipcode(text)
---zipcode have zip and territory channel
i am facing de reference null object please suggest me if any one knows and find below my code....
Public void populateZoneZipTerritory(List<Contact> contactList , Map<Id, Contact> contactOldMap){
set<Id> contId = new set<Id>();
set<string> zipcodeName = new set<string>();
set<string> firmChannel = new set<string>();
Map<string, Zip_Code__c> zipcodeMap = new Map<string, Zip_Code__c>();
Map<Id, Contact> contMap = new Map<Id, Contact>();
for(Contact c : contactList){
if((c.Firm_Channel__c != null)&&(c.Firm_Channel__c != contactOldMap.get(c.Id).Firm_Channel__c)){
contId.add(c.Id);
firmChannel.add(c.Firm_Channel__c);
contMap.put(c.Id, c);
system.debug('*******'+contMap);
}
}
List<Addresses__c> addressList = new List<Addresses__c>([select Id, Zip_Code__c, Contact__c, Address_Type__c from Addresses__c where Address_Type__c = 'Physical' and Contact__c IN :contId]);
for(Addresses__c a: addressList){
zipcodeName.add(a.Zip_Code__c);
}
List<Zip_Code__c> zipcodeList = new List<Zip_Code__c>([select Id,Name,Zone__c,Zone__r.Territory__c,Territory_Channel__c from Zip_Code__c where Name IN :zipcodeName and Territory_Channel__c IN :firmChannel]);
for(Zip_Code__c z :zipcodeList){
zipcodeMap.put(z.Name+''+z.Territory_Channel__c, z);
system.debug('******'+ zipcodeMap);
}
Map<Id, Zip_Code__c> conZipMap = new Map<Id, Zip_Code__c>();
for(Contact c: contactList){
for(Addresses__c a: addressList){
if(a.Contact__c == c.Id){
if(zipcodeMap.containsKey(string.valueOf(a.Zip_Code__c+''+c.Firm_Channel__c))){
conZipMap.put(a.Contact__c , zipcodeMap.get(a.Zip_Code__c+''+c.Firm_Channel__c));
system.debug('&&&&&' + conZipMap);
system.debug('&&&&&' + a.Zip_Code__c+''+c.Firm_Channel__c);--------------> // i got the value here
system.debug('^^^^^^^^'+conZipMap.containsKey(c.Zip_Code__c));
}
}
}
}
for(Contact c: contactList){
if(!conZipMap.containsKey(c.Zip_Code__c)){
if((c.Firm_Channel__c != null)&&(c.Firm_Channel__c != contactOldMap.get(c.Id).Firm_Channel__c)){
c.Zip_Code__c = conZipMap.get(c.Zip_Code__c).Id;------------------->// i need to update zipcode here
system.debug('&&&&&&&' + c.Zip_Code__c);
system.debug('&&&&&&&' + conZipMap.get(c.Zip_Code__c).Id);
}
}
}
}
i am facing the issue here
All Answers
Can you please llet us know in which line you are facing null exception?
-Thanks
Ashlekh Gera
i am facing the issue here