Search code examples
salesforceapexvisualforce

Pass the parameter from the VF page to command button action


I have the VF Page and through a custom button I am passing the parameter To the VF URL as https://abc--c.cs41.visual.force.com/apex/Send_Env_Email?OppId=00655D0Z8 I want to retrieve this within the same page so I can pass it in the command button so call the other controller method

<apex:page  controller="test_Controller1">
  <apex:form >
      <apex:pageBlock >
         <h1>Send a Signing Request via Email</h1>
         <p>This form will send a DocuSign signing request. 
         Are you sure you want to send it?</p> 
         <p><apex:commandButton action="{!send}" onclick="clicked();" rerender="dssdk_output" value="Send!" /></p>
      </apex:pageBlock>  
  </apex:form>

Because the send() within test_Controller1 is looking for the input parameter Public void send(set<id> oppIds)


Solution

  • If I'm understanding correctly what you are trying to accomplish; You don't need to pass it from the page to the controller. You can access url parameters in the controller.

    public pageReference send()
    {
       String oppID = ApexPages.CurrentPage().getParameters().get('OppId');
       --Rest of your code here --
    }
    

    You can then use the oppID to attach to the page you will be redirecting the user to.