Spacing in Word Document When Conditionally Displaying Text

Options

When conditionally displaying text in a Word doc with field reference data, I'm struggling to find a way to remove extra lines of blank space when the conditions aren't met.

As an example, I have multiple optional fields (Field 1, Field 2, Field 3) with field reference names field-1,field-2,field-3. I'm using the format in my document:{{# field-1}}{{field-1}}{{/field-1}}`:

If I only complete Field 3 on a webform, the text for Field 1 and Field 2 don't appear on the Word doc (good) but there's extra spaces where those lines of conditional statements were formatted in my Word template:

Is there a good way to remove these spaces?

Tagged:

Best Answer

  • Jeff_146001
    Jeff_146001 Posts: 296 admin
    Answer ✓
    Options

    @Meghan_153218 I believe you can accomplish this by using the syntax to conditionally display those field values.

    In the Word document, if you input each field name like the following, it should show 1 value per line and skip any lines for which there is no value.

    My choices:{{#choice1}}
    {{choice1}}{{/choice1}}{{#choice2}}
    {{choice2}}{{/choice2}}{{#choice3}}
    {{choice3}}{{/choice3}}
    

    What the code above is saying is, "If there's a value for choice1, then insert a line break and the value for choice 1. (Repeat for choice2 and choice3.)"

Answers

  • Kevin_102667
    Kevin_102667 Posts: 56 admin
    Options

    @Meghan_153218
    Can you dynamically generate the file for the File Template field? That field accept TXT files and you might be able the use other steps to conditionally include/exclude field reference names and generate a TXT file that only includes fields that are not null

  • Meghan_550057
    Options

    That worked perfectly, @Jeff_763648! Thank you!