You need to sign in to do that
Don't have an account?
Redirect to a VF page not working
Hi,
In my organisation, we have VF page to create a new record for an object. It has 2 different record types. We have overridden the New button to open the VF page. This all works fine.
Now there is a requirement to add "Save & New" button in the VF page. I have written code to save and redirect to the record type selection page (hard coded the URL).
Save works fine and redirect is also working normally. But now when i select a record type and click on create, after that an error occurs " Broken URL error".
My code:
public PageReference save_New(){
try {
sController.save();
PageReference pr = new PageReference(<URL given here>);
pr.setRedirect(true);
return pr;
}
catch(Exception e) {
ApexPages.addMessages(e);
return null;
}
What am i doing wrong here?
Alternatively, Is there a standard function for Save & New that I can use?
Any help would be appreciated.
Regards,
Jasleen
Hello Jasleen,
There is must problem with your save functionality. The page redirection code is correct. the only problem with the test senario i.e. record type please try to debug the code. and if possible please add your exception and Page URL here .
All Answers
Hello Jasleen,
There is must problem with your save functionality. The page redirection code is correct. the only problem with the test senario i.e. record type please try to debug the code. and if possible please add your exception and Page URL here .
Hi
Try to remove Try and catch statement and then run ur code then their exist an errror and try to solve this once error is fixed tehn againg u can pu t ur try catch as it is!!!!!!.
Regards,
Rajesh.
Thank you for your replies.
The code works now. I was giving the wrong URL.
But i have another concern now. The validation rules do not work. If I give a value that violates a validation rule and click on "Save & New", the page gets redirected - error is not shown - record is not saved - just redirect happens. The rules work fine if I click on "Save" button(using the standard function for save). What can i do to make the validation rules work for "Save & New"?
Regards,
Jasleen
This problem is happen due to wrong URL. Try to put right URL you will get the solution