Microsoft Word template - if else conditional (Solved)

I am ingesting a jotform and trying to map data to a word template using the Microsoft Word Template module. Based on the documentation found here:

I can do positive conditional based on if something exists, but I would like to have something that shows something within the document based on the choice selected. We have a radio button asking if someone is doing something, it will return a yes or no. I have mapped that as a conditional value and inside my word template I am doing the following:

{{#RadioButton}} This was selected and the user does what we asked{{/RadioButton}}

I would like to do the inverse to insert something into the document if they do not do it, for example, Microsoft allows the replacement of the # sign with a ^ for the negative:

{{^RadioButton}}This was selected and the user is not doing what we asked{{/RadioButton}}

Is there an easy way within the template document we use to populate survey information to have if else conditionals? How much of this module follows the standard Microsoft template spec?

1 Like

Hi @Chris_Smith,

I haven’t worked with this before, albeit I worked with a simpler one with the pre-defined conditions in Make for Templates. I might be wrong, but these templates are based on the vendor that is reformatting those so you might be limited to what Make has to offer for MS Doc templates.

But having said, give the standard formula for MS docs template a try and see if those works for you.

Or, if there are not too many of these if else cases that you want to do, then what you can do is,


{{#hasPhone}}Phone: {{phone}} {{/hasPhone}}
{{#doesnthasPhone}}Phone: {{phone}} {{/doesnthasPhone}}

And, then pass these conditions as required in MS template conditions field.

1 Like

Hi @Runcorn,

Thank you for the reply. As it always happens, the minute I post a question we figured it out.

Here is how we configured the Microsoft Word Template module to handle conditional variables within the actual MS Word Template:

Screenshot 2023-04-27 at 9.24.35 AM

I have redacted the form field selected from the JotForm module that feeds into the MS Word Template module, but the gist is that you have to create a custom variable you will reference inside the word document, and the value needs to be a function to convert the text to boolean values. The input on the survey is a radio button asking a simple yes or no question, but we wanted to input specific data into the word document if yes was chosen. Additionally, if yes was chosen there would be additional form data we would want to bring in and format. For the no condition, we didn’t simply want to omit the data, but add details about the state of the answer.

Here is an example inside the MS Word template file for how you can do if else conditionals, and it follows the MS template standard:

This content is placed within the document based on a positive match

This is how you would change the document content if the custom variable created was false (the only different aside from the content, is the use of the carrot versus the hash mark [# / ^] when declaring the variable:

This content is placed within the document based on the CustomVariable being set to false
1 Like