Documentation Version
Winter '16 (API version 35.0)
  • Winter '16 (API version 35.0) 35.0
  • Summer '15 (API version 34.0) 34.0
  • Spring '15 (API version 33.0) 33.0
  • Winter '15 (API version 32.0) 32.0
  • Summer '14 (API version 31.0) 31.0
  • Spring '14 (API version 30.0) 30.0
  • Winter '14 (API version 29.0) 29.0
  • English

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:


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 and a separate contact
        that is specified by a query string parameter.
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
               <apex:facet name="header">Name</apex:facet>
               <apex:facet name="header">Phone</apex:facet>
    <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/> 
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:
Displaying Field Values with Visualforce has more information about retrieving the ID of a record.


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