Articles in this section

How to group elements and adjust their visibility in a document

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

  • Library and at least one Dynamics modules enabled.
  • Templafy Desktop and Office VSTO add-in installed on the PC.
  • Space owner access to the Templafy tenant.

  Important

The 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.

  1. In Template Designer, navigate to the Template tab.
  2. Select the elements that should be grouped together.
  3. Click + Add smart field.

      Note

    This step doesn't apply if you are adding the very first smart field in the template.

  4. Expand the section by clicking on More.
  5. Click on Group:
    Group_SelectSmartFieldGroup.png
  6. Optionally, edit the Display name.
    The display name will be displayed in the Template tab once the smart field has been added.
  7. Select the desired Visibility
    Group_SelectVisibility.png
    • 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. 
  8. Specify the Visibility for the group.
    Expression builder Custom visibility

    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'

     

    Group_ExpressionBuilder.png

    • 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.
     
  9. 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.

  10. Click Add to template.
    The smart field will be injected into the template and will be displayed in the Template tab.
    Expression builder Custom visibility
    Group_ExpressionBuilderAdded.png

  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.

  Note

This example explains how to display symbols in a document using a Group.
Example 3 explains how to achieve the same result by using symbols (Unicode characters) in a binding.

  1. In Template Designer, navigate to the Form tab.
  2. Click + Add question.
  3. In the Type field, select Checkbox.
  4. In the Question title field, type 'Product A'.
  5. Click Add to form.
  6. In the Word ribbon, on the Insert tab, click Symbol. Then, select the empty checkbox (marked green) to insert the symbol to the template:
    insertsymbol.png

      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':

    symbolwingdings.png

  7. 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').
  8. In the template, after the two inserted symbols, type a space and the text 'Product A'. The result looks like this:
    templatewithcheckboxes.png
  9. In the template, select the first symbol (the empty checkbox).
  10. In Template Designer on the Template tab, click Group:
    templatetabgroup.png
  11. 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:
    templatetabaddgroup.png
  12. Click Add to template.
  13. In the template, select the second symbol (the ticked checkbox).
  14. In Template Designer on the Template tab, click + Add smart field, then click Group.
  15. 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.
  16. Click Add to template. The result looks like this:
    groupcheckboxes.png
  17. Optional: repeat steps 1-16 to add 'Product B', 'Product C' etc..
  18. Save the template and upload it to the Admin Center.
  19. When a user creates (or updates) a document, the result looks like this:
    checkboxesproducts.gif

     

      Tip

    Instead of checkboxes you can also use other symbols like radio buttons:

    symbols.png

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.

  Note

This example explains how to display symbols in a document by using symbols (Unicode characters) in a binding.
Example 2 explains how to achieve the same result by using a Group.

  1. In Template Designer, navigate to the Form tab.
  2. Click + Add question.
  3. In the Type field, select Checkbox.
  4. In the Question title field, type 'Product A'.
  5. Click Add to form.
  6. In the template, type the placeholder text '[Symbol A]' and the text 'Product A'.
  7. Select only the placeholder text. The result looks like this:
    templatewithselectedplaceholder.png
  8. In Template Designer on the Template tab, click Custom text binding:
    templatetabcustomtextbinding.png
  9. In the Binding field, use this binding: {{IfElse(Form.Product_A, "◉", "○")}}. The result looks like this:
    templatetabaddcustomtextbinding.png
  10. Click Add to template. The result looks like this:
    templatewithbinding.png
  11. Optional: repeat steps 1-10 to add 'Product B', 'Product C' etc..
  12. Save the template and upload it to the Admin Center.
  13. When a user creates (or updates) a document, the result looks like this:
    radiobuttonsproducts.gif

      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:
      symbolsdifferentfonts.png
    • 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.
checkbox conditions contains custom text binding custom chart binding tech_role radio button
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.