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. enter image description here

I would expect to get the value from this since the keys are a match.
so why is it null?

enter image description here

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.

  • 5
    note also that map keys are case-sensitive
    – cropredy
    Sep 28, 2023 at 23:33
  • ^^^ is the answer.
    – identigral
    Sep 29, 2023 at 1:42
  • thanks, i just noticed the capitol 'T' ... sigh
    – potato46
    Sep 29, 2023 at 3:57
  • @cropredy You should post that as an answer.
    – Adrian Larson
    Sep 29, 2023 at 13:53

1 Answer 1


Map keys are case sensitive (unlike Apex variable names, Sobject field names, etc)

In your debug log, you have

Detox Admission-Admitted To Facility

But in the copy-paste to System.debug you used

Detox Admission-Admitted to Facility

...To... versus ...to...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .