Joget DX Beta Available for Download
Check out Joget DX, the next generation successor to Joget Workflow for faster, simpler digital transformation.
In this article, we will discuss on how we can control form fields' values saving based on which button is clicked on form submission. Let's use this form as an example.
The business requirement is to not save the value for "Contact" when "Save As Draft" button is used to submit the form.
In the section where the subform is, set the permission of the section to Bean Shell Script.
We will then need to detect when the "Save As Draft" button is clicked or not to determine the next step forward.
When "Save As Draft" button is clicked, the hash variable in the code above will be parsed as "Save As Draft", thus making the equals function return false. In a permission plugin implementation, by returning false, the form fields inside its section will no longer be considered applicable for validation (executing its form validators) and saving (executing form store binder).
The same script can also be placed in the subform's form section permission, or in the subform's form permission too.
With this, the value "c" will only gets replaced with user's input value when "Complete" button is hit, otherwise, it will stays as it is.