One key feature of our user-centric document automation platform is the ability to personalise field labels to the user based on values they have already input into the form. For example, if you have already asked the user someone’s name, you could then dynamically update the label on another field to ask “What is [that person’s name]’s address?”
Form designers can achieve this by including the source field name in ‘double curly brackets’ (i.e. {{}} ) inside the logic for the target form field.
Implementing the double-curly-bracket method for dynamic field labels
To implement this function in the form builder, follow the following steps:
- Note down or copy the source field’s field name. This is the field whose value you want to include in the label for another field. For example: ‘Field_Name_txt’.
- Open the field properties menu for the target field (the field whose label you want to vary), and go to the logic tab.
- Click '+Add logic' and give this piece of logic a name, say: 'Dynamic Label'
- Under Trigger > Container Type select JavaScript and enter the following script:
if (data.Field_Name_txt !== '') {result = true} else {result = false}
This means that the label will only be set this way if the field Field_Name_txt is not empty. - Now, click '+Add action' and give this action a name, say: 'Set Label'
- Under Type, select Property; then under Component Property, select Label; and under Text write the text of your label for example:
What is {{data.Field_Name_txt}}'s address?
- Click 'Save Action', then 'Save Logic' and go to the display tab.
- Under the Label property, input the label as you want it to appear when Field_Name_txt is empty, for example:
What is this person's address?
- Make sure to save the field and you are done!
You should also note the following
If the fields you are referencing and writing to are in a repeat section and you only want to use the reference value in the label for the field in the same row of the repeat, use ‘row.’ instead of 'data.' before the field name.
Combining our two examples, the label in the logic block will read “What is {{data.Field_Name_txt}}’s address?” or “What is {{row.Field_Name_txt}}’s address?”, depending on the context. When the user fills out the form and types in ‘Alice’ as the value for Field_Name_txt, the address question will update to “What is Alice’s address?”
To simplify matters, if you had a label which would work without the need for a default for when the input field was blank, (such as a statement like: "The address of your spouse {{data.Field_Name_txt}}") you can just enter the following code at step 4:
result = true;
Note that single curly brackets are also used in the Submission Settings when referring to the value of a field.
If you have any trouble with dynamic labels, you can submit a request at the top of this page.
Comments
0 comments
Article is closed for comments.