Are the Salesforce Map keys case sensitive ?
I was dealing in a scenario where I was checking case-sensitivity of keys in Salesforce Maps. I read similar issues proposed by 'Mr.Appleman' which he explained beautifully.What I learned at the end of the day is that, for most of the cases the Keys are case-sensitive but for some special cases they are not. Lets quickly check this out
Code below clearly explain the case-sensitivity, copy-paste run anonymously to test
Code below clearly explain the case-sensitivity, copy-paste run anonymously to test
When Maps Keys are not case sensitive then?
When we use dynamic apex to obtain describe information, this indicate that the lookup are case-sensitive and if you apply system.debug(gd) you will find all the object names are stored in lower case.Code below explain global describe and asserting case-sensitivity with 'ContainsKey()'
Now asserting case-sensitivity with 'Keyset.Contains()'
So what is most interesting part here ?
If the key is string then
globalDesc.Keyset().Contains(' ' ) - is case-sensitive
globalDesc.ContainsKey(' ' ) - is not case-sensitive
What to keep in mind ?
When you create the packages and use dynamic SOQL, make sure you are aware about keys-sensitivity
PS : Mr.Appleman
PS : Map Methods
0 comments:
Post a Comment