Description of functionality:
- As a script to perform when changing form field value
- As a script to register on the website
- Globally as a script to run when loading pages
- Globally as a script to run when loading pages and doing postbacks
- As an additional validation script when selecting a path
Example of implemented functionality:
You want to add two features to the existing budget workflow (The description of the workflow can be found in the article: Workflow control):
- Adding the “Change initial amount” checkbox in the “Budget implementation” step. When you select it, the “New initial amount” form field will appear. Following the “Change initial amount” path will result in the change of the “Initial amount”.
Add a “Change initial amount ” Yes / No form field (checkbox) and a “New initial amount” form field to the existing workflow. Add a new “Change initial amount” path, a negative step “Cancelled” and a “Cancel” path which leads to it. Add an action on the “Change initial amount” path that will change the value of the “Initial amount ” attribute to the value of the “New initial amount” form field.
Figure 2. Configuration of the “Change [Initial amount]” action
In addition, you will need another action that counts the remaining funds in the budget on entry to the step:
Figure 3: Configuration of action counting the remaining funds on entry to the “Budget implementation” step
After the changes the workflow should look like this:
Figure 4. Diagram of the budget workflow
Figure 5. Configuration window of form field style and behavior
Figure 6. Creating a script in the wizard
At this point, you already have a set condition saying that when the value of the “Change initial amount” checkbox changes, the “New initial amount” form field will be shown or hidden. However, it is still displayed by default. Move on to edit the “Budget implementation” step:
Figure 7. Edit the „Budget implementation” step
Figure 9. “Change initial amount” path parameters
This time you have to use your own script which, in case you do not enter any value, will display a message and prevent you from following the path.
Now you need to realize the other functionality – the window in which you must confirm your intention to cancel the budget. To do this, go to the details of the “Cancel” path in the “Budget implementation” step.
Figure 11. Parameters of the “Cancel” path
Just as was the case for the validation of the “Change initial amount” path, you must use your own script now. Its purpose is to display a dialog box with an OK / Cancel choice. If the user confirms, the document will follow the path.
Verification of functionality:
We register the document so that it gets to the “Budget implementation” step:
Figure 13. Registration of the budget
Next verify the operation of the checkbox. You can see that the “New initial amount” form field is invisible. The form field will be displayed only when you check the “Change initial amount” option.
Figure 14. Form view after loading the page
When you click on the checkbox, leave the “New initial amount” form field blank and try to follow the “Change initial amount” path.
We fill in the required form field and then try to follow the path.
It worked. In Figure 17 you can see that “Initial amount” and “Other funds” have been set up correctly. All that remains now is to check if the additional validation on the “Cancel” path is working. When you click “Cancel”, a dialog box will appear asking you if you really want to cancel the document.
If you click on “Cancel”, you will stay in the current step. If you click “OK”, you will follow the “Cancel” path.