You need to sign in to do that
Don't have an account?
RAM R
How to get the values from the map , please suggest me?
HI , i am facing de-reference null object please suggest me the solution and find below my code..
trigger zipcodeupdateTrigger on Contact (after insert, after update) {
set<string> zipcodeName = new set<string>();
set<string> firmchannelName = new set<string>();
Map<Id, Zipcode__c> zipCodeMap = new Map<Id, Zipcode__c>();
List<Contact> updateList = new List<Contact>();
//Map<Id, Address__C> addressMap = new Map<Id, Address__C>();
List<Address__C> addressList = new List<Address__C>([select id, Name, contact_Level__C, zipcode__c from Address__c where type__C = 'physical']);
for(Address__c a:addressList){
//addressMap.put(a.zipcode__C, a);
firmchannelName.add(a.contact_level__c);
zipcodeName.add(a.Zipcode__c);
}
List<Zipcode__C> zipList = new List<zipcode__c>([select id, Name from Zipcode__c where Name IN :zipcodeName]);
for(Zipcode__c z: zipList){
zipCodeMap.put(z.Id, z);
}
for(Contact c:trigger.New){
Zipcode__C zp = zipcodeMap.get(c.zipcode__c);------------------->i am not able to get the value?
if((c.Level__c != null) && (c.Level__c != trigger.oldMap.get(c.Id).Level__C)){
system.debug('********* : '+ zp.Name);
c.zipcode__c = zp.Name;
updateList.add(c);
system.debug('********* : '+ zp.Name);
}
}
Update updateList;
}
trigger zipcodeupdateTrigger on Contact (after insert, after update) {
set<string> zipcodeName = new set<string>();
set<string> firmchannelName = new set<string>();
Map<Id, Zipcode__c> zipCodeMap = new Map<Id, Zipcode__c>();
List<Contact> updateList = new List<Contact>();
//Map<Id, Address__C> addressMap = new Map<Id, Address__C>();
List<Address__C> addressList = new List<Address__C>([select id, Name, contact_Level__C, zipcode__c from Address__c where type__C = 'physical']);
for(Address__c a:addressList){
//addressMap.put(a.zipcode__C, a);
firmchannelName.add(a.contact_level__c);
zipcodeName.add(a.Zipcode__c);
}
List<Zipcode__C> zipList = new List<zipcode__c>([select id, Name from Zipcode__c where Name IN :zipcodeName]);
for(Zipcode__c z: zipList){
zipCodeMap.put(z.Id, z);
}
for(Contact c:trigger.New){
Zipcode__C zp = zipcodeMap.get(c.zipcode__c);------------------->i am not able to get the value?
if((c.Level__c != null) && (c.Level__c != trigger.oldMap.get(c.Id).Level__C)){
system.debug('********* : '+ zp.Name);
c.zipcode__c = zp.Name;
updateList.add(c);
system.debug('********* : '+ zp.Name);
}
}
Update updateList;
}
NOTE: This code has not been tested and may contain typographical or logical errors