Controlling step flow

From pmusers
Jump to: navigation, search

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:

StepFlow-processMapImage.png

In that task, create three Dynaforms. The first Dynaform will contain a dropdown box associated with a variable named "clientType":

StepFlow-clientTypeFormInDesigner.png

In this dropdown box, the user can select whether the client is an "Individual", "Business" or "Contracted Service":

StepFlow-optionsInClientTypeDropdown.png

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'

StepFlow-IndividualDetailsFormCondition.png

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'

StepFlow-BusinessDetailsFormCondition.png


When a case is run, and the user select "Business" in the "Client Type" dropdown:

StepFlow-BusinessClientTypeSelected.png

Then, the "Business Details" form will be skipped and the "Business Details" form will be displayed:

StepFlow-BusinessDetailsFormShown.png

On the other hand, if the user selects "Individual" in the "Client Type" dropdown:

StepFlow-IndividualClientTypeSelected.png

Then, the "Individual Details" form will be displayed and the "Business Details" form will be skipped:

StepFlow-IndividualDetailsFormShown.png