I ran into this issue and believe this is a Salesforce bug, and I am looking for confirmation.

Maps are supposed to be key case sensitive but when we use the pageReference.getParameters.put() it does not support case sensitivity.

Here is example code:

PageReference pg1 = new PageReference('/' + 'somevalue' + '/e');

pg1.getParameters().put( 'oppid' , 'somevalue1' );
pg1.getParameters().put( 'OPPID' , 'somevalue2' );

system.debug( pg1.getParameters() );
system.debug( pg1.getUrl() );

Result debug:

USER_DEBUG [6]|DEBUG|{oppid=somevalue2}
USER_DEBUG [8]|DEBUG|/somevalue/e?oppid=somevalue2

I believe both values should be maintained and written as urlparameters.

i.e. the result should be /somevalue/e?OPPID=somevalue2&oppid=somevalue1

Is this behavior a bug?


According to getParameters() documentation, Parameter keys are case-insensitive

    ApexPages.currentPage().getParameters().get('oppid') ==
  • 2
    Ah. Nice to know the documentation calls this out. – sfdcfox Dec 21 '17 at 19:11

The query string case sensitivity is platform dependent. Apex Code, based on Java, follows Java's rules: parameter names are case insensitive. As such, any map that manipulates a query string will use case insensitive keys. This isn't a bug so much as a feature. Case insensitive parameters simplifies query parameter access. However, this also means you can't have two case-insensitive keys in the same URL. If you explicitly need this feature, you'll have to build your query string manually. You'll find several other maps that also behave this way, like Schema.getGlobalDescribe, DescribeSobjectResult's fields map, and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.