You need to sign in to do that
Don't have an account?
Stephanie Stoddard
How to redirect to VF page from VF form standard controller?
I have a VF page that creates a contact, but I want the form to redirect to a Thank You page rather than try to open the newly created contact in SF. Here is my extension coding:
public class ContactSaveExtension {
ApexPages.StandardController controller;
public ContactSaveExtension(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference saveAndRedirect() {
controller.save();
PageReference redirect = new PageReference('ApexPage.Thank_You');
redirect.setRedirect(true);
return redirect;
}
}
What am I missing?
Thank you!
public class ContactSaveExtension {
ApexPages.StandardController controller;
public ContactSaveExtension(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference saveAndRedirect() {
controller.save();
PageReference redirect = new PageReference('ApexPage.Thank_You');
redirect.setRedirect(true);
return redirect;
}
}
What am I missing?
Thank you!
Please use below page reference class.To return another vf page syntax is ('/apex/pagename').
Thank
Varaprasad
All Answers
Please use below page reference class.To return another vf page syntax is ('/apex/pagename').
Thank
Varaprasad
In your code, you have written the wrong statement for redirect the page.
your statement is:
please try this one
Thanks
Mukesh Kumar
I have test this code my side, Please use this
Please MARK AS A BEST ANSWER !!!!!
Regards
Mukesh
The next issue I am facing is getting to 75% code coverage to deploy in my production environment (I'm at 63%). I have not written any test code for this Apex Class. Is writing test code helpful, and if so, what would be an example?
Thank you!