+ Start a Discussion
Ola BamideleOla Bamidele 

Page Reference having issues - Urgent!

Hi Gurus, 

I have this code to redirect users to a different page when a link is clicked. However, this apex code doesnt seems save and therefore not working. i am getting an error stating.

Missing return statement required return type: System.PageReference - Line 10

Does anyone know why my code isnt working?

Thanks very much,
Ola
Ola BamideleOla Bamidele
This is my code: 
public with sharing class CustomerSatTest{
  public String currentRecordId {get;set;}
  public String VFPageName{get;set;}

  public CustomerSatTest (ApexPages.StandardController controller){
    this.currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
  }
  
    
  public PageReference RedirectHelper (String VFPageName) {                   
  		  this.VFPageName = VFPageName;
                  pageRedirect();
  }
 
      public PageReference pageRedirect() {                   
  		   PageReference pageref = new 
                     PageReference('/apex/' + VFPageName + '?Id='+currentRecordId); 
                     pageref.setRedirect(true);
                     return pageref;
  }


 
}

Please if you kjow why it isnt workin, please let me know!

Thanks,
Ola
SandhyaSandhya (Salesforce Developers) 
Hi,

As the erroe message clearly says there is no return statement at line no 10.

Change the code to
public PageReference RedirectHelper (String VFPageName) {                   
  		  this.VFPageName = VFPageName;
                  return pageRedirect();
  }

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
Ola BamideleOla Bamidele
Hi Sandhya, 

Ohh okay, that worked! 

I am getting an error when I put the Apex code page name in my Visualforce pafge header. 

From line 15, am i suppose to another enter my visualforce page name aswell?

Thanks very much!