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
Scott0987Scott0987 

Save and continue button

I have a pretty large visualforce page that I am having people fill out.  I have set about 50 fields on it to be required like <apex:inputfield required="true" value="{!var1}">  I want the field to be required so that before they can finish the page they need to fill that field out.  I would also like to give them a "Save and Continue" button so that they can save their progress.  I want this button to bypass the required flag but it needs to pass the variable var1 to the method so that it saves it.  Then I want a second save button that enforces the required flag.  Is there anyway to do this?

Cory CowgillCory Cowgill

You can use the immedieate attribute on a CommandButton to bypass validation so that it won't validate it.

 

Save would have immediate="false".

Save and Continue would have immediate="true".

 

http://blogs.developerforce.com/developer-relations/2008/12/using-the-immediate-attribute-on-commandlinks-and-commandbuttons.html

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_commandButton.htm

Scott0987Scott0987
The problem with the Immediate="true" option is that it does not pass the variables or any changes to the method. So while it does bypass required flags it does not allow you to update the actual fields. At least that is what it seems to do.
ScriptMonkeyScriptMonkey

This may be an idea from left field, but it might work just the way you need it.  Validation rules (rather than layout required fields) can be conditional.  If you have a hidden field of "skip validation" or something like that, and have the save and continue button check that with the onclick method, then your validation rules can validate only when it's not checked (meaning the user used the save button).

 

Scott0987Scott0987

I think you are right ScriptMonkey