I want to create a custom save button.By Clicking this button, I should save the record and redirect to another VF page which I created to view. Please give me suggestions How to perform redirecting and saving the record in one button.



In order to accomplish the desired functionality, you are going to want to use the PageReference class to do something like this:

 public PageReference save() {
    // Add the account to the database. 
    insert account;
    // Send the user to the custom visualforce page for the new account.
    PageReference acctPage = new PageReference('/apex/myVfAccountPage?Id='+account.Id);
    return acctPage;

You can check out the documentation here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.