+ Start a Discussion

URL Parameter isn't coming through

Summary: I've created a button that is displayed on a custom object. When clicked, I want this button to redirect the user to a Visualforce page with some parameters being passed from the current record. Here's the applicable section of code from the Button, VF Page, and Controller:


Button (This code is taking the value of the current records Week Start Date and Position and passing it into variables on the visualforce page):





Visualforce Code:

Normally 'BegDate' and 'Positions' are generated from user input. BegDate is a text field (that receives dates: MM/DD/YYYY) and Positions is a drop down box that matches the position field on each Shift Object.




    <strong>Please enter the first day of the schedule you would like to see (mm/dd/yyyy):</strong> <apex:inputText value="{!BegDate}"/>
    <apex:selectList value="{!Positions}" Size="1">
        <apex:selectOptions value="{!items}"/>
        <apex:actionSupport event="onchange"></apex:actionSupport>



Here is the controller code for handling this input:



    public String getPositions() {
        return Positions;
    public void setPositions(String Positions) {
        this.Positions = Positions;

    //Initializes and provides a get method for the user inputted date
    String BegDate;
    public String getBegDate (){
        return BegDate;

     public void setBegDate (string BegDate) {
         this.BegDate = BegDate;



Then of course these variables are used throughout the controller - but this is how they are brought in and initialized. What I'd like is for the current records values to be passed to the page when clicking the button - but I want the user to maintain the ability to also go to the visualforce page and enter their own input. This page is used to view and edit our schedule.


Any help would be greatly apprecaited - I read and attempted it quite a bit, but I've reset my code back to this default because it wasn't working.









I should mention that the URL from the button looks perfect - the correct information is showing up in the URL - it just doesn't appear to have any effect on the page loading - The page loads as if there was no values for those variables.


Did you find a solution to this problem? I think I'm experiencing the same issues. I'm passing parameters to a URL in my PageReference and the values appear in the URL, but are not passed through to the fields.


Thank you!



Hey Sam,

Unfortunately I was not able to find a solution for this. I left the enhancement out of my release and have not revisited it.

If you find a solution, please share it with me!

I finally realized that while I had put the parameters in the URL, I wasn't getting them from the URL and putting them into the fields. In your controller you'll want to define:

   BegDate = ApexPages.currentPage().getParameters().get('BegDate');

   Positions = ApexPages.currentPage().getParameters().get('Positions');


Since I'm not sure how your Salesforce instance & controller are structured, here's how I resolved the issue:


Background: I have a custom button on a custom object (DocReq__c). This button redirects to a Visualforce Page where my users can create a related custom object (People__c).


Custom Button URL: '/apex/InvolvedPartyEdit/docReq__c={!DocReq__c.Id}&exec={!DocReq__c.Type__c}'


Constructor from Controller class:

public saveIPNewBuy(ApexPages.StandardController ctlr) {

    peep = (People__c)ctlr.getRecord();

    peep.DocReq__c = ApexPages.currentPage().getParameters().get('docReq__c');

    peep.Executable__c = ApexPages.currentPage().getParaemters.get('exec');



I hope this helps!