How-To Choices In Workflows
Choosing Paths based on Toggle, Dropdown, or Segment Fields
Workflows are most useful when you can use the information entered by your field workers to drive the decision process. This is done using a combination of a Read Asset/Job/Request connector and Exclusive Branching conditions.
On each branch apart (apart from the default) you define a condition that must be met for that branch to run. With Exclusive Branching only one branch must match, so each condition must be exclusive (ie not overlap). The easiest way to do this is to use Toggle, Dropdown, or Segment Fields. For simple yes/no or on/off, use a toggle and then have two branches - set one to yes/on and leave the default as no/off. For Dropdowns or Segmented fields, you should set up one branch for each individual case that needs special handling and then let the default branch handle all other cases. Using these three fields types ensures that the conditions will be exclusive.
A text field empty/not empty test is also very good for exclusive testing.
The branching conditions also support things like equal or not equal to an arbitrary text string, before, after or between dates and times. These are also very useful and should be used but take care - if you have many branches you will need to make sure the conditions can’t accidentally overlap.
Consider the Exit Inspection workflow shown above (click on the diagram to zoom it up). This is a simple version of the process that a property management company may follow at the end of a residential tenancy.
It starts with an Exit Inspection trigger (1). When an Exit Inspection request is Accepted, this workflow is run. The next step is to read the data in the Inspection form (2).
The third box is an Exclusive Branch. It checks a field “Did the property pass inspection?”, which is a toggle field in the Exit Inspection form. If it passed inspection then it takes the path shown at (4). This goes straight to creating the email to the letting manager that the inspection process is complete.
If it failed the inspection then it goes to the maintenance section, shown in the blue dotted outline.
Node (6) is a parallel branching. Each branch is done at the same time. This way the cleaning and the garden maintenance can all be done by different people but they don’t need to wait for each other. Each branch continues at its own pace and at (10) Gruntify will wait till all three branches are completed before proceeding.
Nodes (7), (8), and (9) are all Exclusive Branches, following the same pattern. The fields “Needs Internal Clean”, “Needs External Clean”, and “Needs Garden Maintenance” are segmented fields, with the values “No”, “Tenant to Organize” and “Agent to Organize”.
The branch tests are set up so that if the value = “Agent to Organize” then the “AGENT TO…” branches are taken and a job created to get the work done. If either “No” or “Tenant to Organize” are selected then the default branch is used and no action is taken by the agent. All the work should be completed before the Reinspection (10) is done. When the Reinspection is complete (11) then the workflow can go on with triggering the email.
The movie below is from the Example Workflow Building page and covers how to set up the branches using the form data in detail.
How do I do an AND test?
In the Check Morning Start example, we wanted to check that morning client jobs are started in the morning, not in the afternoon. When we analyse this test this means “is a client job AND should start in morning”, or “clientId is not empty AND the startTime is between 6am and 11:59am”.
We have done this by nesting our tests. In the workflow picture below, we first check that it is a client job. If it is, then we check the start time. You could put them in either order - client job check first or morning start check first.
Tip for Advanced Users: For performance, the rule of thumb is to first do a simple test which will reduce greatly the number of matches. For example, say we know 50% of our jobs are client jobs, and 90% of them start in the morning. We test the client job first because it is the simpler test for the computer to do (ie is this field empty) and then the check the time which will take longer (doing two time comparisons) will only be done for half of the jobs.
Related articles