Skip to main content

Form condition rules

In this article, we explain rules that can be used in forms to hide and calculate components.

Written by Cameron Falconer
Updated this week

You can use conditional expressions to show or hide form components based on the value of another component. This helps tailor the form experience based on user input.

Example

We need to hide the component Details of support required, if the value of the question Standing is Independent or if the question Standing has not been answered.

Each form component has a unique ID. You'll use this ID to write expressions.

  • Standing = form_component_142

  • Details of support required = form_component_163

To hide Details of support required, use one of the following:

  1. If Standing is Independent
    (form_component_142 = "Independent")

  2. If Standing is NOT Support Required
    (form_component_142 != "Support Required")

πŸ“Œ Note: Values like "Independent" are case sensitive and must match exactly what's in the form designer.


Best practice

Do

  • Use !form_component_X?has_content to check if a field has a value.

  • Double-check your syntax β€” small typos can break functionality.

  • Hide entire sections instead of individual fields for better performance.

Don't

  • Try to hide fields inside tables β€” this won't work.

  • Leave trailing spaces in dropdown, radio, checkbox, or multi-select options β€” spaces are treated as characters.


Conditional reference table

πŸ“Œ Note: The examples in this table use placeholder component IDs and values from a sample form. Replace the example component IDs and values with those from your own form.

Hide rules

Scenario

Rule

Outcome

Hide form_component_2 if form_component_1 has content

(form_component_1?has_content)

Field is hidden when form_component_1 has a value

Hide form_component_2 if form_component_1 has NO content

(!form_component_1?has_content)

Field is hidden when form_component_1 is empty

Hide form_component_2 if form_component_1 is NOT equal to Yes

(form_component_1 != "Yes")

Field is hidden when value is not "Yes"

Hide a component if one of two conditions is true (OR)

(form_component_1 = "Yes") || (form_component_2 = "No")

Field is hidden if either condition is true

Hide a component if both conditions are true (AND)

(form_component_1 = "Yes") && (form_component_2 = "No")

Field is hidden only if both conditions are true

Show a field if Other is selected in a checkbox

(!(form_component_78?has_content) || !(form_component_78?contains("Other")))

Field is hidden unless Other is selected

Calculate rules

Scenario

Rule

Outcome

Calculate total score from 4 components

(form_component_1 + form_component_2 + form_component_3 + form_component_4)

Returns the sum of all components

Assign numerical value to dropdown option

[#elseif form_component_2 = "Requires improvement"]
[#assign form_component_2 = 5]

Assigns value 5 to the selected option

Assign outcome if score is missing

[#if !form_component_1?has_content]
[#assign form_component_1 = "No outcome Calculated"]

Displays "No outcome Calculated" when score is empty

Round BMI calculation to one decimal place

((form_component_1 / ((form_component_2 / 100) * (form_component_2 / 100)))?string("0.#"))

Returns BMI rounded to one decimal place


Troubleshooting β€” form rules not working correctly

If a conditional rule or calculate rule is not behaving as expected, work through the checks below before raising a support case.

The score is not calculating or shows zero. Form scores are calculated server-side when the form is submitted or when a rule is evaluated. A score will not update in real time as you complete the form. Check the following:

  • All source fields used in the calculate rule must have a numeric value at submission time. If any source field is empty or contains non-numeric data (such as text in a Number field), the calculation will fail silently.

  • The component IDs in the rule expression must exactly match the IDs of the source fields. Go to the form in Configuration > Forms, open the relevant component, and verify the component ID. A mismatch will cause the rule to produce no result.

  • For dropdown or radio fields used in scoring, the option values assigned in the calculate rule must match the text of the dropdown options exactly, including case and spacing. A trailing space in the dropdown option or in the rule will cause a mismatch.

A conditional rule is not hiding or showing a field correctly. The most common causes are:

  • The text value in the rule expression does not match the field option exactly. All conditional expressions are case-sensitive. "Yes" and "yes" are treated as different values.

  • The component ID in the rule expression does not match the component being referenced. Check the component ID in the field settings within Configuration > Forms.

  • You are attempting to use a hide rule on a field inside a table. Hide rules cannot be applied to fields within tables. This is a known limitation.

  • The conditional logic contains a syntax error. Even a single misplaced bracket or quotation mark will cause the rule to fail. Review the expression against the reference table above.

A Waterlow, risk assessment, or other multi-field scoring form is returning an incorrect total. These forms typically assign numeric values to dropdown selections and then sum them into a total field. If the total is incorrect:

  1. Open the form in Configuration > Forms and review the calculate rule on the total field.

  2. Check each dropdown option in the source fields. The values assigned in the rule (e.g. [#assign form_component_X = 2]) must match the text of the dropdown options exactly.

  3. Check whether any source fields were added or renamed since the rule was created. If a field was renamed, its component ID will have changed and the rule must be updated to reference the new ID.

  4. Submit a test version of the form with known values and compare the expected total against what the system calculates. This helps isolate which component is not mapping correctly.

A hidden mandatory field is blocking form submission. If a carer or administrator cannot submit a form despite all visible fields being completed, a hidden mandatory field may be preventing submission.

When a field is hidden by a condition rule, the server checks whether that field is in the list of components the form identified as hidden at the time of submission. If the field is not correctly registered as hidden β€” for example, because the condition rule has a syntax error, because the rule was evaluated differently between the web and mobile platforms, or because the hiding logic did not execute before submission β€” the server may still treat the mandatory field as required and block submission.

To resolve this:

  1. Open the form in Configuration > Forms and locate the hidden mandatory field.

  2. Review the condition rule on that field. Confirm the expression is syntactically correct and that the source component ID is accurate.

  3. If the field should never be mandatory when hidden, consider removing the mandatory flag from it and instead enforcing mandatory entry through instruction or process rather than form validation.

  4. Test the form by completing it and triggering the hide condition, then attempting to submit. If submission still fails, check the browser console for any error response from the server.

⚠️ Note: A server-side fix for hidden mandatory fields blocking form submission was shipped in ACP Server 8.2.8. A separate Android-specific variant of this issue (ADO 1802155) is currently open and unscheduled. If you are on a server version below 8.2.8 and experiencing this issue, update to 8.2.8 or later. If you are on 8.2.8 or above and still seeing this on Android, raise a support case with the form name, the component ID of the hidden mandatory field, and the condition rule expression.

πŸ“Œ Note: If you have checked all of the above and the rule is still not behaving correctly, raise a support case via the Access Digital Assistant. Include the form name, the component ID of the field with the rule, the full rule expression, and an example of the expected versus actual output.

Did this answer your question?