function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How do you set id as query string parameter in URL on custom page

I want to see Id as query string parameter in URL of my custom page. How can I get it and set it?
Peter FribergPeter Friberg
Usually parameters in the Salesforce url when accessing a visualforce page are added after the page name.
First parameter is always prepended by '?' then parameter name '=' value.
All other parameters are always prepended by '&' then parameter name '=' value
Example below:

To get parameters in Apex controller for the visualforce page use this technique:
String firstparam = ApexPages.currentPage().getParameters().get('firstparam');
String secondparam = ApexPages.currentPage().getParameters().get('secondparam');
String thirdtparam = ApexPages.currentPage().getParameters().get('thirdtparam');
Good luck!
sandeep madhavsandeep madhav
Can we encode the url so that the id should not be exposed.
Thanks Peter. I understood how parameters are appended in Salesforce url and how to get them through Apex Controller. I want to know how to append ID if its not adding it by default.For example, I am creating custom page with Contact fields. When I click Save , will the ID be appended automatically or do I need to set it with code? I created a page and when I tested it. It does not show any parameters but the contact record is updated