Articles in this section

How to adjust the visibility of smart fields

This article explains how to adjust the visibility of smart fields based on specific conditions so they can be visible, hidden or deleted when generating the document.

  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

Please note that the Template tab is only available in Word and PowerPoint. Inserting information into a Spreadsheet for Excel can be done through the Header Footer in the Advanced tab.

Often, when building smart templates some elements might require to be visible, hidden, or deleted based on specific conditions. The Visibility option on the smart field level can be used for that purpose and requires the use of the binding syntax. Follow the steps below to a add a visibility expression:

Create a visibility binding with the Expression builder

  1. Create the necessary smart field.
  2. Open the Advanced section.
    Visibility_OpenAdvanced.png
  3. Select Expression builder in the Visibility dropdown.
    Visibility_SelectBuilder.png
  4. Create the desired Visibility condition by adding values to the IF, THEN and ELSE fields:
    Visibility_Condition.png
    In the 'Write a string or binding here' IF field you can type a binding like Form.Title or {{Form.Title}} (if you type curly brackets they will be removed when the field is saved), or you can type a string like "Introduction". Include the double quotes in case of a string.
    Form field String Empty value
    Visibility_Condition-form.png

      Important

    • Field of type Checkbox is not supported in the Expression builder.
    • The Expression builder can be used to quickly create a simple binding. After the binding is created you (optionally) can switch the view to Custom visibility and manually create a more advanced binding by modifying the binding that is shown in the Visibility expression field.

Create a visibility binding manually with Custom visibility

  1. Create the necessary smart field.
  2. Open the Advanced section.
    Visibility_OpenAdvanced.png
  3. Select Expression builder in the Visibility dropdown.
    Visibility_SelectCustom.png
  4. Type in the desired binding in the Visibility expression to adjust the smart field visibility.
    Visibility_CustomExpression.png

  Important

  • Note that using VisibilityType.Delete will prevent 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 smart field.
  • After a content control is deleted with VisibilityType.Delete nothing will be shown anymore (so also no placeholder with 'Click or tap here to enter text').
  • VisibilityType.Delete is not supported in PowerPoint.
  • In Word, the Group smart field can be used to group several elements together and adjust their visibility.

Visibility expression examples

Show or hide the smart field based on the value of a checkbox in the response form
Using the IfElse() function with Checkbox to determine visibility of a binding based on the value of 'Form.Introduction'. Binding:
{{IfElse(Form.Introduction, VisibilityType.Visible,VisibilityType.Hidden)}}

  Example 1 Example 2
Input Checkbox is checked Checkbox is not checked
Condition True False
Output VisibilityType.Visible VisibilityType.Hidden
Show or hide the smart field based on the value of a question in the response form
Using the IfElse() function to set visibility of a binding based on the value of 'Form.Subject'. Binding:
{{IfElse(Equals(Form.Subject, "Introduction"), VisibilityType.Visible, VisibilityType.Hidden)}}

  Example 1 Example 2
Input Form.Subject = "Introduction" Form.Subject = "Product"
Condition True False
Output VisibilityType.Visible VisibilityType.Hidden
Show or delete the smart field based on the value of a dropdown question in the response form
Using the IfElse() function to set visibility of a binding based on a Dropdown. Binding:
{{IfElse(Equals(Form.Confidentiality.Name, "Public"), VisibilityType.Visible, VisibilityType.Delete)}}

  Example 1 Example 2
Input Form.Confidentiality.Name = "Public" Form.Confidentiality.Name = "Confidential"
Condition True False
Output VisibilityType.Visible VisibilityType.Delete
Show or hide the smart field based on the value of a dropdown question originating from the user profile
Using the IfElse() function together with Contains() to display or hide some text based on the value of the 'Office.Name' originating from the User Profile. If the 'Office.Name' is "Copenhagen" or "Berlin", the text should be hidden. If the 'Office.Name' is anything else, the text should be shown. Binding:
{{IfElse(Contains("Copenhagen, Berlin", UserProfile.Office.Name), VisibilityType.Hidden, VisibilityType.Visible)}}

  Example 1 Example 2 Example 3
Input UserProfile.Office.
Name =
"Berlin"
UserProfile.Office.
Name =
"Copenhagen"
UserProfile.Office.
Name =
"Eindhoven"
Condition True True False
Output VisibilityType.Hidden VisibilityType.Hidden VisibilityType.Visible
custom text binding custom chart binding tech_role
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.