Slaesforce FAQ

how to pass dynamic id in pagereference salesforce

by Miss Hassie Sauer Jr. Published 2 years ago Updated 2 years ago
image

You can do this by passing a get parameter. PageReference opptyPage = new PageReference ('/apex/PBXOrdering'); opptyPage.getParameters ().put ('id', Opportunity.id); opptyPage.setRedirect (true); return opptyPage ; Share

Full Answer

How do I get the account of a page in Salesforce?

The getAccount method uses an embedded SOQL query to return the account specified by the id parameter in the URL of the page. To access id, the getAccount method uses the ApexPages namespace: First the currentPage method returns the PageReference instance for the current page.

What is a pagereference in Salesforce?

A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values. Refers to a PageReference for a Visualforce page that has already been saved in your organization.

How to create a partial URL page reference in Salesforce Lightning?

PageReference pageRef = new PageReference('partialURL'); Creates a PageReference to any page that is hosted on the Lightning platform. For example, setting 'partialURL' to '/apex/HelloWorld' refers to the Visualforce page located at http://mySalesforceInstance/apex/HelloWorld.

How do I get query parameters from a page in Visualforce?

First the currentPage method returns the PageReference instance for the current page. PageReference returns a reference to a Visualforce page, including its query string parameters. Using the page reference, use the getParameters method to return a map of the specified query string parameter names and values.

image

Request Headers

The following table is a non-exhaustive list of headers that are set on requests.

Example: Retrieving Query String Parameters

The following example shows how to use a PageReference object to retrieve a query string parameter in the current page URL. In this example, the getAccount method references the id query string parameter:

Example: Navigating to a New Page as the Result of an Action Method

Any action method in a custom controller or controller extension can return a PageReference object as the result of the method. If the redirect attribute on the PageReference is set to true, the user navigates to the URL specified by the PageReference.

Example: Redirect Users to a Replacement Experience Cloud Site

The following example shows how to redirect a user attempting to access a retired feedback site to a self-service help site. If the redirect attribute is set to true on the PageReference for the feedback site, the user navigates to the URL specified by the PageReference.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9