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
Chanagan SakulteeraChanagan Sakulteera 

Why I can't open visualforce page from visualforce page

Hi all,
I'm new for salesforce help me please. Why I can't open visualforce page by button.
This is my code

public PageReference onSave(){
        upsert(lstProductService);
        String url = 'Cost_Calculator_2?&CF00NO0000001EtuG_lkid='+theProduct.Id+'&CF00NO0000001EtuG='+theProduct.Name;
        PageReference pref=new PageReference('/'+url);
        return pref;
    }

This is my page.
User-added image

This code in visualforce page.
             <center><apex:commandButton value="Save" action="{!onSave}"/></center>

I want open the another page by visualforce page.
Thank you for ans.
Best Answer chosen by Chanagan Sakulteera
Gil GourévitchGil Gourévitch
Hi,
Maybe you can try to add "apex" at the beginning of the url :
String url = 'apex/Cost_Calculator_2?&CF00NO0000001EtuG_lkid='+theProduct.Id+'&CF00NO0000001EtuG='+theProduct.Name;
Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !

 

All Answers

Navee RahulNavee Rahul

Are you sure that ​onSave  method is called ??. i mean did you debug it .??

did you try redirecting to some static pages??.

 

Gil GourévitchGil Gourévitch
Hi,
Maybe you can try to add "apex" at the beginning of the url :
String url = 'apex/Cost_Calculator_2?&CF00NO0000001EtuG_lkid='+theProduct.Id+'&CF00NO0000001EtuG='+theProduct.Name;
Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !

 
This was selected as the best answer