Articles in this section

How to show or hide a question based on the answer to another question (gating questions)

This article explains how to setup up gating questions. This means a question is shown or hidden based on the answer to another question. This way only relevant questions are shown to the user.

To create this, you need to setup a template with a dropdown where the user can select an answer. The selected answer will insert a text element (or slide) with specific questions. Depending on the possible answers you need to create multiple text elements (or slides), each with their own set of questions (form fields). It's also possible to setup a template with a checkbox (that shows a gating question when the checkbox is checked), but in this article a dropdown is used.

Gating questions can be created in Word (using text elements) and PowerPoint (using slides).

  Prerequisites

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

What is needed to create a template with gating questions?

To create a template with gating questions you need the following:

  • A template with a dropdown to choose from.
  • One or more text elements or slides containing specific questions (form fields).
  • A data source (used for the dropdown) that contains a column with the Asset ID's of the text element(s) or slide(s) to be inserted.

  Important

  • Dynamic text element insertion (the inserted text element also contains questions) or dynamic slide insertion is only supported for dropdown or checkbox form fields. When a flexible dropdown is used then the questions from the text element or slide will not be shown.
    Tip: for dynamic insertion using checkbox form fields see Example 3 on this page for Word or Example 3 on this page for PowerPoint.
  • A nested text element (text element used in another text element) or nested slide is not supported.
    Form fields that show up cannot include dropdowns that trigger additional form fields to show up. This means only two levels of gating questions are supported: the initial question and the additional questions shown depending on the user's choice in the first question.

Example of gating questions in Microsoft Word

In this example a dropdown is created where the user can choose to order a pencil or a ruler. When the pencil is chosen the next question will be a dropdown to choose a color. If the ruler is selected then the next questions will be dropdowns to choose the desired length and material. The user will also have the option to order nothing, in that case no additional question will be shown.

Tip: read the article about Using smart fields in Word before continuing with this example.

Create the 'Pencil' text element

  1. Create a data source named 'Colors' and add some colors to the Name column. The result looks like this:
    datasourcecolors.png
  2. Create a new template named 'Pencil'.
  3. In Template Designer on the Form tab, click + Add question and create a Dropdown form field with these values:
    • Type: 'Dropdown'.
    • Question title: 'Choose color'.
    • Data source: 'Colors'.
    • Label column: 'Name'.
  4. The result looks like this:
    formdropdowncolor.png
  5. Click Add to form.
  6. In the template type a placeholder text for the color (e.g. '[Color]'). Select the placeholder.
  7. On the Template tab click Form responses, expand Choose_color and select Name.
  8. Click Add to template. The result looks like this:
    contentcontrolcolor.png
  9. Save the template as 'Pencil.docx' and upload it to the asset library 'Text elements' in the Admin Center.

Create the 'Ruler' text element

  1. Create a data source named 'Sizes' and add some sizes to the Name column. The result looks like this:
    datasourcesizes.png
  2. Create a data source named 'Materials' and add some materials to the Name column. The result looks like this:
    datasourcematerials.png
  3. Create a new template named 'Ruler'.
  4. In Template Designer on the Form tab, click + Add question and create a Dropdown form field with the values below. Then click Add to form:
    • Type: 'Dropdown'.
    • Question title: 'Choose size'.
    • Data source: 'Sizes'.
    • Label column: 'Name'.
  5. Click + Add question again and create a Dropdown form field with the values below. Then click Add to form:
    • Type: 'Dropdown'
    • Question title: 'Choose material'.
    • Data source: 'Materials'.
    • Label column: 'Name'.
  6. In the template type a placeholder text for the size (e.g. '[Size]'). Select the placeholder.
  7. On the Template tab click Form responses, expand Choose_size and select Name.
  8. Click Add to template.
  9. Next type a placeholder text for the material (e.g. '[Material]'). Select the placeholder.
  10. On the Template tab click + Add smart field, then click Form responses, expand Choose_material and select Name.
  11. Click Add to template. The result looks like this:
    contentcontrolsizematerial.png
  12. Save the template as 'Ruler.docx' and upload it to the asset library 'Text elements' in the Admin Center.

Create the 'Invoice' template

Now it's time to create the template. It will contain a dropdown where the user can choose between 'Pencil' (that inserts the 'Pencil' text element), 'Ruler' (that inserts the 'Ruler' text element) or 'Nothing'.

  1. Create a data source named 'Choice' with a Name and AssetID column (of Type 'Text').
  2. Create a record with the Name 'Nothing' and leave the AssetID field empty.
  3. Create a record with the Name 'Pencil'. In the AssetID field enter the Asset ID of the 'Pencil' text element (click the three dots behind the 'Pencil' text element in the Admin Center, then click Copy asset ID and paste the value in the AssetID field in Template Designer).
  4. Create a record with the Name 'Ruler'. In the AssetID field enter the Asset ID of the 'Ruler' text element. The result looks like this:
    datasourcechoice.png
  5. Create a new template named 'Invoice'.
  6. In Template Designer on the Form tab, click + Add question and create a Dropdown form field with the values below. Then click Add to form:
    • Type: 'Dropdown'.
    • Question title: 'Choose product'.
    • Data source: 'Choice'.
    • Label column: 'Name'.
    • Default value: 'Nothing'.
  7. On the Form tab, click + Add question and create a Text form field with the values below. Then click Add to form:
    • Type: 'Text'.
    • Question title: 'Closing'.
    • Prefill text: 'Thanks for your order!'.
  8. In the template type a placeholder text for the product (e.g. '[Product]'). Select the placeholder.
  9. On the Template tab click Form responses, expand Choose_product and select Name.
  10. Click Add to template.
  11. In the template type a placeholder text for the product text element (e.g. '[TE_Product]', where 'TE' is short for 'Text Element'). Select the placeholder.
  12. On the Template tab click + Add smart field, then click Text element.
  13. In the Asset ID field type the binding {{Form.Choose_product.AssetID}} and enable Replace On Update. The result looks like this:
    templateassetid.png

      Important

    • You need to use a binding to the data source like {{Form.Choose_product.AssetID}}. If you would type the Asset ID of a text element instead then this text element would always be inserted and in this case that should not happen; depending on the choice of the user, nothing should be inserted, or the 'Pencil' or 'Ruler' text element.
    • The binding is case sensitive.
    • The option Replace On Update is enabled because that allows the user to change the answer after the document is created, using Update document.
      If the option
      is not enabled then the dropdown would not be shown anymore.
    • A text element (content control) needs to be placed in it's own paragraph (or table cell). Using a text element in a sentence is not supported.
     
  14. Click Add to template.
  15. In the template type a placeholder text for the closing (e.g. '[Closing]'). Select the placeholder.
  16. On the Template tab click + Add smart field, then click Form responses and select Closing.
  17. Click Add to template. The result looks like this:
    contentcontrolstemplate.png
  18. If you open the Form tab note that a field named 'Placeholder 1' has been added (1). This determines where the questions (form fields) from the text element will appear in the task pane.
    Since it makes no sense to show the questions after the 'Closing' question, move the 'Placeholder 1'
     up, so that it is positioned below the related 'Choose product' question (2).
    Finally rename 'Placeholder 1' to 'Product'
    . The result looks like this (3):
    placeholder.png

     

      Note

    • When you add a Text Element smart field then a placeholder for the text element is automatically added. By default the Placeholder field (see image from step 13) shows 'Generate new'. This will create a (new) placeholder named 'Placeholder 1', 'Placeholder 2' etc.
    • It's not required to rename a placeholder, but if a template has many placeholders then names like 'Product', 'Disclaimer' etc. are easier to recognize then 'Placeholder X'.

     

  19. Save the template as 'Invoice.docx' and upload it to the asset library 'Documents' in the Admin Center.

Creating a document

When a user creates a document with the template then by default 'Nothing' is selected in the 'Choose product' dropdown and no additional (dropdown) questions are shown.
If the user selects 'Pencil' then one additional dropdown 'Choose color' is shown and when 'Ruler' is selected the two additional dropdowns 'Choose size' and 'Choose material' are shown:
gc_gatingquestions.gif

When the user selects 'Pencil' then the result in the document looks as shown in example 1 below.
When 'Ruler' is selected then the result looks as shown in example 2:

invoice.png

When the user selects 'Nothing' then the result looks as shown in example 3.
Of course it makes no sense to thank someone for an order if nothing has been ordered!
Also you might want to hide the complete line 'Product: Nothing' in this case. This is beyond the topic of this article, but if you want to hide text in a document based on certain conditions then you can do this by adjusting the visibility which is explained in this article and this article.

Example of gating questions in Microsoft PowerPoint

Creating gating questions in PowerPoint basically works the same as creating them in Word as shown in the example above (therefore a brief explanation in this example). In this example a dropdown is created where the user can choose to insert a slide showing a project plan with timeline. If the slide is inserted then a 'Project title' question will be shown.

Tip: read the article about Using smart fields in PowerPoint before continuing with this example.

Create the 'Project timeline' slide

  1. Create a new template named 'Project timeline'.
  2. In Template Designer on the Form tab, click + Add question and create a Text form field named 'Project title'.
  3. Click Add to form.
  4. In the template insert a shape at the position where you want to display the project title.
  5. Select the shape, then on the Template tab expand Form responses, select the Project_title form field and click Add to template:
    formresponsesprojecttitle.png

     

      Note

    If the Add to template button is greyed out then you need to reselect the shape.

  6. The result looks like this:
    titleplaceholderbinding.png

     

      Note

    The layout used in the slide above is just an example.
    Only the ProjectTitle field is important.

  7. Save the template as 'Project timeline' and upload it to the asset library 'Slides' in the Admin Center.

Create the 'Project proposal' template

Now it's time to create the template. It will contain a dropdown where the user can choose between 'Yes' (that inserts the 'Project timeline' slide) or 'No' (nothing will be inserted).

  1. Create a data source named 'Options' with a Name and AssetID column (of Type 'Text').
  2. Create a record with the Name 'No' and leave the AssetID field empty.
  3. Create a record with the Name 'Yes'. In the AssetID field enter the Asset ID of the 'Project timeline' slide (click the three dots behind the 'Project timeline' slide in the Admin Center, then click Copy asset ID and paste the value in the Asset ID field in Template Designer). The result looks like this:
    datasourceoptions.png
  4. Create a new template named 'Project proposal'. Add one or more slides (in this example 3 slides are added - see image shown in step 8).
  5. In Template Designer on the Form tab, click + Add question and create a Text form field with the values below. Then click Add to form:
    • Type: 'Text'.
    • Question title: 'Customer name'.
  6. On the Form tab, click + Add question and create a Dropdown form field with the values below. Then click Add to form:
    • Type: 'Dropdown'.
    • Question title: 'Insert Project timeline slide?'.
    • Data source: 'Options'.
    • Label column: 'Name'.
    • Default value: 'No'.
  7. In the template insert a shape at the position where you want to display the customer name (in this example it's inserted in the lower left corner on the first slide).
  8. Select the shape, then on the Template tab expand Form responses, select the Customer_name form field and click Add to template. The result looks like this:
    customernameplaceholderbinding.png
  9. Now select the position where you want the 'Project timeline' slide to be inserted when the user chooses 'Yes'.
    If you want the slide to be inserted between slides '2' and '3', then select slide '2' (in the following steps the placeholder slide will then be inserted after slide '2') on the left of the screen:
    gc_slidesthumbnails.png
  10. On the Template tab click + Add smart field, then click Slide(s):
    slides.png
  11. In the Display name field type a name for the field (e.g. '[SL_ProjectTimeline]', where 'SL' is short for 'Slide') and in the Asset ID field type the binding {{Form.Insert_Project_timeline_slide.AssetID}}. Then click Add to template:
    slideassetid.png
  12. The result looks like this:
    placeholderbinding.png

     

      Note

    • A placeholder slide is added (after slide '2'). When a user chooses 'Yes', then this will be the place where the 'Project timeline' slide will be inserted.
    • Note that on the Form tab now a field named Placeholder 1 has been added. This determines where the question (form field) from the slide will appear in the task pane.
      You can rename the field and/or change the position (as described in step 18 from the Word example above), but this is optional.
  13. Save the template as 'Project proposal' and upload it to the asset library 'Presentations' in the Admin Center.

Creating a presentation

When a user creates a presentation with the template then by default 'No' is selected in the 'Insert Project timeline slide?' question and no additional questions are shown.
If the user selects 'Yes' then the additional dropdown 'Project title' is shown:

gc_gatingquestion.gif

When the user selects 'No' then the result looks like this (3 slides):

gc_presentation.png

  Note

Note that the 'Insert Project timeline slide?' dropdown is only shown on initial creation of the presentation. When the user clicks Update document then only the 'Customer name' field is shown, but the 'Insert Project timeline slide?' dropdown will not be available anymore.

When 'Yes' is selected then the result looks like this (4 slides):

gc_presentationwithslide.png

  Note

  • When the user clicks Update document then the 'Customer name' and 'Project title' fields are shown, but the 'Insert Project timeline slide?' dropdown will not be available anymore.
  • In this example only 1 slide is inserted, because the 'Project timeline' template only contains 1 slide.
    If the template had e.g. 3 slides, then 3 slides would have been inserted.
slides dynamics text elements smart fields hide form field show question gating question show form field hide question
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.