Getting Query String Parameters

You can reference query string parameters in Visualforce markup by using the $CurrentPage global variable. Using $CurrentPage, you can access the query string parameters for the page by specifying the parameters attribute, after which you can access each individual parameter:

$CurrentPage.parameters.parameter_name

For example, suppose you want to add detail information about a specific contact to an Account page. The account record ID is specified by the default id query string parameter, and the contact record ID is specified by the query string parameter named cid:

<apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are displaying values from the {!account.name} account and a separate contact
        that is specified by a query string parameter.
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
              <apex:column>
               <apex:facet name="header">Name</apex:facet>
                {!contact.Name}
              </apex:column> <apex:column> <apex:facet name="header">Phone</apex:facet> {!contact.Phone}
              </apex:column> </apex:dataTable> </apex:pageBlock> <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/> </apex:page>
For this example to render properly, you must associate the Visualforce page with valid account and contact IDs in the URL. For example, if 001D000000IRt53 is the account ID and 003D000000Q0bIE is the contact ID, the resulting URL should be:
https://Salesforce_instance/apex/MyFirstPage?id=001D000000IRt53&cid=003D000000Q0bIE
Displaying Field Values with Visualforce has more information about retrieving the ID of a record.
Note
If you use the id parameter in a URL, it must refer to the same entity referred to in the standard controller.
Using Query String Parameters in a Page A Visualforce page that uses query string parameters
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.