0

This may be been asked before (I couldn't locate it), but given the below example. I need to create a url for a custom field, but the case changes. Is there a simple way around this to keep the original VisualForce page text case. I know Apex is case-insensitive, so not sure sure if there is a simple fix for this.

Let's say the page is called TestPage.

PageReference testPage = Page.TestPage;
testPage.getParameters().put('param', 'value');
// This will return '/apex/testpage?param=value' as opposed to '/apex/TestPage?param=value'
System.debug(testPage.getUrl());
5
  • have you tried instantiating the page reference like new PageReference('/apex/TestPage')? If I remember correctly, this preserved lower/upper case for me. – Antonio Manente Sep 14 '16 at 16:24
  • 3
    Why do you care? – Adrian Larson Sep 14 '16 at 16:27
  • @AdrianLarson I don't. The client does. – Andrew L. Sep 14 '16 at 17:41
  • 1
    Then you should ask them why it makes a difference. – Adrian Larson Sep 14 '16 at 17:41
  • 1
    @AdrianLarson I like the way you think. It shouldn't matter. – Andrew L. Sep 14 '16 at 18:33

Your Answer

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

Browse other questions tagged or ask your own question.