I'm creating a map based on a custom object in my org. Basically this is the code for it.
Map<String, String> translationMap = new Map<String, String>();
List<StageNameTranslation__c> myTranslations = [Select RecordTypeName__c, LS_StageName__c, SF_StageName__c from StageNameTranslation__c];
for(StageNameTranslation__c t: myTranslations) {
translationMap.put(t.RecordTypeName__c + '-' + t.LS_StageName__c, t.SF_StageName__c);
}
Then I use the .get method to get the value for a specific key. In this scenario I have hard-coded the key as a string for testing. the "combined" variable.
String combined = 'Detox Admission-Admitted to Facility';
String mappedStageName = translationMap.get(combined); // equal to translationMap.get('Detox Admission-Admitted to Facility')
System.debug('mappedStageName: ' + mappedStageName); // expect to get the value .. in this case 'Admitted To Facility'
Since I am facing this issue, I print out every key/value in the map
for(String key : translationMap.keyset()){
system.debug('The Current Key ='+ key);
system.debug('The Current value ='+ translationMap.get(key));
}
the system.debug for the String variable mappedStageName is null However when I look at the debugs, I copy and paste the key(the 'combined' variable), and it is a match for the key in the map.
I would expect to get the value from this since the keys are a match.
so why is it null?
I even copy and pasted the key from the debug and did:
System.debug(translationMap.get('Detox Admission-Admitted to Facility'));
and that returned null as well.