This article explains how to group elements in a document based on specific conditions so they can be visible, hidden, or deleted when generating the template.
Prerequisites
|
ImportantThe Group smart field is only available in Word. |
Often, when building smart documents some elements should be visible, hidden, or deleted based on specific conditions using IfElse() statements, the Group smart field can be used for that purpose. Follow these steps below to create a Group smart field.
Example 1 - Show or hide labels and values
Show or hide the 'Your ref' and 'Our ref' labels and values in a document.
- In Template Designer, navigate to the Template tab.
- Select the elements that should be grouped together.
- Click + Add smart field.
Note
This step doesn't apply if you are adding the very first smart field in the template.
- Expand the section by clicking on More.
- Click on Group:
- Optionally, edit the Display name.
The display name will be displayed in the Template tab once the smart field has been added. - Select the desired Visibility:
- Always show: the group will always be displayed without any conditions.
- Expression builder: the group will be displayed based on a (simple) condition using the Expression builder.
- Custom visibility: the group will be displayed based on a visibility expression (binding) that is typed.
- Specify the Visibility for the group.
The template contains a text form response field 'Your_reference'. The sentence regarding 'your reference' is selected and a Group smart field using the Expression builder is created. The Visibility condition is:
IF 'Form.Your_reference' 'Is empty' THEN 'Hide' ELSE 'Show'
- If the question is filled by the user, the 'your reference' group is visible in the document.
- If the question is not filled by the user, the 'your reference' group is hidden in the document.
The template contains a checkbox form response field, called 'Include_references'. The text regarding the references is selected, and a Group smart field using a Custom visibility is created. The Visibility expression is:
{{IfElse(Form.Include_references, VisibilityType.Visible, VisibilityType.Hidden)}}
- If the checkbox is checked, the references group is visible in the document.
- If the checkbox is not checked, the references group is hidden in the document.
- Optionally, perform an additional action on the smart field:
Allow updates: Allow the smart field to be updated after its generation when edited by the user through the Document content updater. This option will not be visible if the document content updater is not enabled on the smart template.
Important
Using
VisibilityType.Delete
will prevent the Allow updates option to work as it will delete the content control on document generation which will effectively disable the Document content updater for this group. - Click Add to template.
The smart field will be injected into the template and will be displayed in the Template tab.
Note
|
Example 2 - Show empty or ticked checkbox
Show an empty or ticked checkbox in a document, depending on the answer of the end-user.
NoteThis example explains how to display symbols in a document using a Group. |
- In Template Designer, navigate to the Form tab.
- Click + Add question.
- In the Type field, select Checkbox.
- In the Question title field, type 'Product A'.
- Click Add to form.
- In the Word ribbon, on the Insert tab, click Symbol. Then, select the empty checkbox (marked green) to insert the symbol to the template:
Note
If the empty checkbox is not shown, click More Symbols..., select the Wingdings font, and then select the symbol with Unicode name 'Wingdings: 168':
- On the ribbon, click Symbol again. Now, select the ticked checkbox (marked blue in step 6, this is the symbol with Unicode name 'Wingdings: 254').
- In the template, after the two inserted symbols, type a space and the text 'Product A'. The result looks like this:
- In the template, select the first symbol (the empty checkbox).
- In Template Designer on the Template tab, click Group:
- Set the Visibility to Custom visibility. In the Visibility expression field, use this binding:
{{IfElse(Form.Product_A, VisibilityType.Hidden, VisibilityType.Visible)}}
.
Optional: change the Display name. The result looks like this: - Click Add to template.
- In the template, select the second symbol (the ticked checkbox).
- In Template Designer on the Template tab, click + Add smart field, then click Group.
- Set the Visibility to Custom visibility. In the Visibility expression field, use this binding:
{{IfElse(Form.Product_A, VisibilityType.Visible, VisibilityType.Hidden)}}
.
Optional: change the Display name. - Click Add to template. The result looks like this:
- Optional: repeat steps 1-16 to add 'Product B', 'Product C' etc..
- Save the template and upload it to the Admin Center.
- When a user creates (or updates) a document, the result looks like this:
Tip
Instead of checkboxes you can also use other symbols like radio buttons:
Example 3 - Show empty or selected radio button
Show an empty or selected radio button in a document, depending on the answer of the end-user.
NoteThis example explains how to display symbols in a document by using symbols (Unicode characters) in a binding. |
- In Template Designer, navigate to the Form tab.
- Click + Add question.
- In the Type field, select Checkbox.
- In the Question title field, type 'Product A'.
- Click Add to form.
- In the template, type the placeholder text '[Symbol A]' and the text 'Product A'.
- Select only the placeholder text. The result looks like this:
- In Template Designer on the Template tab, click Custom text binding:
- In the Binding field, use this binding:
{{IfElse(Form.Product_A, "◉", "○")}}
. The result looks like this: - Click Add to template. The result looks like this:
- Optional: repeat steps 1-10 to add 'Product B', 'Product C' etc..
- Save the template and upload it to the Admin Center.
- When a user creates (or updates) a document, the result looks like this:
Important
- You can use Unicode characters like these (you can copy/paste them): ○◉☐☑☒, but be aware that the Font you select in Word affects the appearance of the characters!
In the example below you can see that when you use the 'Aptos' font the last checkbox is bigger then the other ones, and when you use 'Arial' the first radio button is smaller. When you use e.g. 'Segoe UI Symbol', the size of all characters is the same: - Instead of typing the text 'Product A' directly in the template, as shown in the image from step 7, you can also choose to type the text in the binding instead. The binding from step 9 would then look like this:
{{IfElse(Form.Product_A, "◉", "○")}} Product A
While this works, keep in mind that if you use e.g. the 'Segoe UI Symbol' font for the symbol, that the text 'Product A' then also will be using that font! Also the text will have the same font size as the symbol.
- You can use Unicode characters like these (you can copy/paste them): ○◉☐☑☒, but be aware that the Font you select in Word affects the appearance of the characters!
Comments
Article is closed for comments.