function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gautamgautam 

passing id from one vf page to other vf page

Hi All,

 

I have 3 vf pages .!st page is eventdetails page where i have all outputfields showing event details .In this page i have a button called proceed for registration .The controller code for this page is

 

public  class  Proceedbutton {
     
     private  final  ApexPages.StandardController  controller;
 
     public  Proceedbutton (ApexPages.StandardController  stdController) {
         this.controller =  stdController;
    }
    
    
    
   Static Id id1=ApexPages.currentPage().getParameters().get('id');
    
    
    
    public  PageReference  proceed()
    {
         Pagereference  EventRegister=  Page.EventRegister;
         EventRegister.setRedirect(True);
         return  EventRegister;
         
    }
    Public static Id getid()
    { return id1;}
    }

Here in this controller I am trying to get the event id in the id1 variable after that it goes to Eventregister page.

 

 

In Eventregister page,User enters his information and clicks register .Here I have controller which stores the data and goes to tranks vf page .

 

Here’s the code

 

public  class  Registerbutton {

     private  final  ApexPages.StandardController  controller;
 
     public  Registerbutton (ApexPages.StandardController  stdController) {
         this.controller =  stdController;
    }
    
     public  PageReference  Register()
    {
       Registrant__c   reg = (Registrant__c)controller.getRecord();
       
       
       reg.Event__c=Proceedbutton.getid();
       //reg.Event__c='a06S0000002VZMw';
       insert  reg;
       Pagereference  EventThankyou =  Page.EventThankyou  ;
       EventThankyou.setRedirect(True);
       return  EventThankyou;
    }
    }

 

 

In this controller , just before saving the registrant record, I am calling the getid() method on proceedbutton controller to get the eventid .I am trying to link all registrants to that event by doing so.Event__c is a lookup field on Registrant object pointing to Event object

 

But I am not getting the expected result  in the line reg.Event__c=Proceedbutton.getid();

 

Can anyone please help me what I am doing wrong here ?

Best Answer chosen by Admin (Salesforce Developers) 
suresh.csksuresh.csk

Hey

 

follow this example

 

Page#1 your sumbit button Apex code

 

public PageReference Sumbit(){

      PageReference tosecondpage = Page.secondpage;
      tosecondpage.getParameters().put('paramID',acc.ID);
      tosecondpage.setRedirect(true);
        return tosecondpage;
       }

 

Page#2   Apex code

 

String accountID

 

public void intSecondPage(){

accountID= ApexPages.currentPage().getParameters().get('paramID');
}

 

cheers

suresh

 

 

 

 

All Answers

suresh.csksuresh.csk

Hey

 

follow this example

 

Page#1 your sumbit button Apex code

 

public PageReference Sumbit(){

      PageReference tosecondpage = Page.secondpage;
      tosecondpage.getParameters().put('paramID',acc.ID);
      tosecondpage.setRedirect(true);
        return tosecondpage;
       }

 

Page#2   Apex code

 

String accountID

 

public void intSecondPage(){

accountID= ApexPages.currentPage().getParameters().get('paramID');
}

 

cheers

suresh

 

 

 

 

This was selected as the best answer
gautamgautam

Thanks a lot ..Its working as expected...