function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RAM RRAM R 

how to call map in the below code?

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))){
values---------->  conZipMap.put(a.Contact__c ,  zipcodeMap.get(string.valueOf(a.Zip_Code__c+''+c.Firm_Channel__c)));                        
                        system.debug('&&&&&' + conZipMap);
                        system.debug('&&&&&' + a.Zip_Code__c+''+c.Firm_Channel__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)){                    
                    system.debug('*****'+conZipMap.get(c.Zip_Code__c);
     -------->         c.Zip_Code__c = conZipMap.get(c.Zip_Code__c);-----------> how can i  call the above map and assigned that zipcode here 
                    system.debug('&&&&&&&' + c.Zip_Code__c);
                    system.debug('&&&&&&&' + conZipMap.get(c.Zip_Code__c).Id);
                }
            }
        }
Best Answer chosen by RAM R
AshlekhAshlekh
Hi,

At the time of creating map , you are using "a.contact__c" as a key.
conZipMap.put(a.Contact__c ,  zipcodeMap.get(string.valueOf(a.Zip_Code__c+''+c.Firm_Channel__c)));
So if you need to get the value of from map then you need to provide id of contact.
 
c.Zip_Code__c = conZipMap.get(Id of conatct which is c.id);-----------> how can i  call the above map and assigned that zipcode here

-Thanks
Ashlk