Best Practices and Tips
Since Advanced Form Builder (AFB) offers so much flexibility in creating expressions for the Ignore, Visible, and Enable attributes, below are some tips to help you achieve desired results.
- If you want to set up a display rule for an object that is based on the exact answer of that object (and it is set up to only allow one answer): Use the Equals syntax below
- If you want to set up a display rule for an object that is based on a specific answer of that object (and it is set up to allow multiple answers): Use the Includes syntax below
- If you want to set up a display rule for an object that is based on an object being answered with any answer: Use the Any answer syntax below
Examples: Any Object
The syntax examples below can be applied to any of the Ignore, Visible, or Enable attributes on any objects )except the special cases as noted below):
EQUALS: a rule is triggered if unique ID is chosen as the only answer
Syntax: {{ adminUnit==('<insert the unique ID for unit>') }}
Sample: {{ adminUnit==('73bdc65a-e243-48b5-80eb-e73d4dcb2cdd') }}
How: AFB Expression builder, manual
INCLUDES: a rule is triggered if unique ID is chosen singly or in a group of answers
Syntax: {{ adminUnit.includes('<insert the unique ID for unit>') }}
Sample: {{ adminUnit.includes('73bdc65a-e243-48b5-80eb-e73d4dcb2cdd') }}
How: Create Simple Expression, manual
ANY ANSWER: a rule is triggered if any answer is chosen
Syntax: {{ adminUnit.length > 0 }}
How: AFB Expression builder, Create Simple Expression, manual
Examples: AU/NZ Classification Code Objects
The following examples can be applied to any of the Ignore, Visible, or Enable attributes on the AU/NZ Classification Codes objects:
EQUALS: a rule is triggered if unique ID is chosen as the only answer
Syntax: {{ flw.mapAttr(fORCode, 'code')==('<insert unique ID for FOR Code>') }}
Sample: {{ flw.mapAttr(fORCode, 'code')==('330101') }}
How: AFB Expression builder, manual
INCLUDES: a rule is triggered if unique ID is chosen singly or in a group of answers
Syntax: {{ flw.mapAttr(fORCode, 'code').includes('<insert unique ID for FOR Code>') }}
Sample: {{ flw.mapAttr(fORCode, 'code').includes('330101') }}
How: Create Simple Expression, manual
ANY ANSWER: a rule is triggered if any answer is chosen
Syntax: {{ flw.remove.nulls(flw.mapAttr(fORCode, 'code')).length > 0 }}
How: AFB Expression builder, Create Simple Expression, manual
Examples: Funding Program Objects
The examples below can be applied to any of the Ignore, Visible, or Enable attributes on the Funding Program objects:
EQUALS: a rule is triggered if unique ID is chosen as the only answer
Syntax: {{ flw.mapAttr(fundingProgram, 'id')==('<insert unique ID of Funding Program>') }}
Sample: {{ flw.mapAttr(fundingProgram, 'id')==('54f0eac2-eec9-4deb-888e-3e10bfa5dd4f') }}
How: AFB Expression builder, manual
INCLUDES: a rule is triggered if unique ID is chosen singly or in a group of answers
Syntax: {{ flw.mapAttr(fundingProgram, 'id').includes('<insert unique ID of Funding Program>') }}
Sample: {{ flw.mapAttr(fundingProgram, 'id').includes('54f0eac2-eec9-4deb-888e-3e10bfa5dd4f') }}
How: Create Simple Expression, manual
ANY ANSWER: a rule is triggered if any answer is chosen
Syntax: {{ flw.remove.nulls(flw.mapAttr(fundingProgram, 'id')).length > 0 }}
How: AFB Expression builder, Create Simple Expression, manual
AFB Known Issues
1. A blank, non-null expression is erroneously being created in the Ignore, Visible and Enable attributes when the user accesses the AFB expression builder via the hamburger icon and
-
- clicks OK without entering any data
- clicks OK after clearing an expression via the Reset Expression function (without entering a new expression)
The user may not notice the issue until they attempt to publish the form. At that time, the user will see an error (shown in the screenshots in the Comments) which directs them to the Section and Question that has the error along with the message “<Ignore, Visible, Enable> attribute contains a blank, non-null value”
To fix the issue, the user must select the lightning bolt next to the attribute to reset it and ensure the attribute’s checkbox is set as desired
2. With the Create Simple Expression function, users can append multiple conditions within the same expression by using the Create Simple Expression function multiple times before clicking OK. With this ability, it is important to note the following scenarios and best practices:
- Expression exists in expression text field
- Another expression is created using the Create Simple Expression function
Result: Expressions will be appended
- User deletes all text from the expression text field
- Another expression is created using the Create Simple Expression function
Result: Deleted expression will be restored and the new expression appended to it
Best Practices
- Ensure only the desired expression remains before clicking OK
- Delete the existing expression, click OK and then re-edit to add the new expression