Activity Forums Salesforce® Discussions How can I take parameters from one page to another with different controllers in Salesforce?

  • Himanshu

    Member
    April 30, 2016 at 2:20 pm

    Hi Rachit,

     

    Try this link:-http://www.forcetree.com/2009/06/passing-parameters-to-visualforce-page.html

    Hope this helps you.

  • PRANAV

    Member
    January 31, 2018 at 9:38 am

    Hi,

    You can use the below code snippet for this

    public Pagereference gotonewpage()
    {
    PageReference pageRef = Page.existingPageName;
    pageRef.getParameters().put('msg','success');
    return PageRef
    }

    This will make your URL looks like this //na5.salesforce.com/apex/SamplePage2?msg=success

    Retrieve Parameter Values in Apex Class:

    public class Sampleclass
    {
    Public String message = System.currentPagereference().getParameters().get('msg');
    }

    Hope this helps you.

     

  • Parul

    Member
    September 18, 2018 at 10:15 am

    Hi,

    Step 1: Create a Visualforce page called SamplePage1

    <apex:page >
    <apex:outputlink value="/apex/SamplePage2"> Click Here <apex:param name="msg" value="success"/> </apex:outputlink>
    </apex:page>

    Step 2: Create a Visualforce page called SamplePage2

    <apex:page controller="Sampleclass"> </apex:page>

    Step 3: On SamplePage1 Click on the " Click Here" link. You will see that when you click on the link you will navigate to the SamplePage2. Check the URL now..

    https://na5.salesforce.com/apex/SamplePage2?msg=success

    You can see that the parameter " msg" with value "success" has been passed to the new page.

    Retrieve Parameter Values in Apex Class:

    public class Sampleclass
    {
    Public String message = System.currentPagereference().getParameters().get('msg');
    }

    Thanks

  • shariq

    Member
    September 21, 2018 at 12:04 am

    Hi,

    In the code segment below we are passing two parameters along the page url – ownerid and eventid :

    PageReference newPage =
    new PageReference('/apex/cys_meeting_rooms?ownerid='+event.OwnerId+'&eventid='+event.Id);
    return newPage.setRedirect(true);
    Now here is how to get these values on second VF page :

    In salesforce we can get parameter values from the current page url by using global variable $CurrentPage. We can use CurrentPage.parameters.parameterName to reference page request parameters and values, where parameterName is the request parameter being referenced.

    For the page url invoked above, we can display the value of eventid parameter in the page url on our VF page as :

    <apex:outputText value="{!$CurrentPage.parameters.eventid}">
    It will display the values of the page parameter eventId as output text on the VF page.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs