Controlling step flow
Conditions in steps can be used to control whether a DynaForm, Input Document or Output Document is displayed to the user or skipped. In addition, the PMFRedirectToStep() function in triggers. can be used to redirect to a particular step (DynaForm, Input Document, Output Document or External Step) inside a task. This example shows how to use a condition to display DynaForms based on the selection in a dropdown box.
Process: StepFlow-Skip_steps_with_conditions.pmx (right click and select Save link as)
Tested in: ProcessMaker 3.2.3 Community in Debian 9.5
Create a process which has a task:
In that task, create three Dynaforms. The first Dynaform will contain a dropdown box associated with a variable named "clientType":
In this dropdown box, the user can select whether the client is an "Individual", "Business" or "Contracted Service":
This form to select the "Client Type" is the first step in the task. The second form is an "Individual Details" form that will only be shown to the user if "Individual" was selected in the "Client Type" dropdown box. The third form is a "Business Details" form that is only shown to the user, if "Business" or "Contracted Service" was selected.
To control whether the "Individual Details" form is displayed to the user, click on its Properties button and enter the following condition:
@@clientType == 'individual'
The condition checks for a value selected in the dropdown box. If wishing to check for the label selected in the dropdown box, then use the
@@variable_label variable in the condition like this:
@@clientType_label == 'Individual'
When writing conditions, remember that
== (a double equals sign) is equality in PHP, whereas
= (a single equals sign) is for variable assignment. Do NOT use a single equals sign in conditions, because it will assign the value to the variable, which will evaluate to
true and the DynaForm will always be displayed. Also remember to enclose strings in either single or double quotations marks, as shown in the example. The
Then, click on the Properties button for the "Business Details" form and add the following condition:
@@clientType == 'businesss' or @@clientType != 'individual'
When a case is run, and the user select "Business" in the "Client Type" dropdown:
Then, the "Business Details" form will be skipped and the "Business Details" form will be displayed:
On the other hand, if the user selects "Individual" in the "Client Type" dropdown:
Then, the "Individual Details" form will be displayed and the "Business Details" form will be skipped: