Skip to content

Jobs and Conditional Logic

Conditional logic builds on the sections functionality and allows you to expose or hide sections based on questions asked in other custom fields.

This is done by adding an array of conditions to the custom field that is driving the logic. Sections can be exposed based on the content of either checkbox or picklist custom fields.

The following example adds an array of two conditions to the "Ready to Mow" picklist.

If the answer selected is yes, the conditions expose the section called "Yes, I can mow."

If the answer selected is no, then the conditions expose the section called "No, I can't mow."

These other sections can contain mandatory custom fields that only become mandatory when these sections are exposed.

<sections type="array">
      <section>
            <title>Job Details</title>
            <custom_fields type="array">
                  <custom_field>
                        <name>Ready to Mow</name>
                        <value/>
                        <type>pick_list</type>
                        <pick_list_id>14652</pick_list_id>
                        <conditions type="array">
                              <condition>
                                    <value>Yes</value>
                                    <section>Yes I can Mow</section>
                              </condition>
                              <condition>
                                    <value>No</value>
                                    <section>No I cant Mow</section>
                              </condition>
                        </conditions>
                  </custom_field>
            </custom_fields>
      </section>
      <section>
            <title>Yes I can Mow</title>
            <custom_fields type="array">
                  <custom_field>
                        <name>Mowing Done</name>
                        <value>0</value>
                        <type>checkbox</type>
                        <permission>required</permission>
                  </custom_field>
            </custom_fields>
      </section>
      <section>
            <title>No I cant Mow</title>
            <custom_fields type="array">
                  <custom_field>
                        <name>Too Wet</name>
                        <value>0</value>
                        <type>checkbox</type>
                  </custom_field>
                  <custom_field>
                        <name>No Access</name>
                        <value>0</value>
                        <type>checkbox</type>
                  </custom_field>
            </custom_fields>
      </section>
</sections>

The example below exposes the "Spraying Section" when the tickbox is checked for "Are you spraying today?".

<custom_fields type="array">
    <custom_field>
        <name>Are you spraying today?</name>
        <value>0</value>
        <type>checkbox</type>
        <conditions type="array">
            <condition>
                <value>1</value>
                <section>Spraying Section</section>
            </condition>
        </conditions>
    </custom_field>
</custom_fields>
<sections type="array">
    <section>
        <title>Spraying Section</title>
        <custom_fields type="array">
            <custom_field>
                <name>Chemicals Used</name>
                <value></value>
                <type>text</type>
                <permission>required</permission>
            </custom_field>
            <custom_field>
                <name>Wind Direction</name>
                <value></value>
                <type>pick_list</type>
                <pick_list_id>97813</pick_list_id>
                <permission>required</permission>
            </custom_field>
        </custom_fields>
    </section>
</sections>

The XML for conditional logic can become quite verbose. The easiest way to work with conditional logic is to create the template using the website template editor and then GET that template via the API. This will give you all the XML you need to create a matching job.