If statements can be used to conditionally add content to your generated PDF/Word document under defined conditions.

The basic syntax of an if statement is:

{% if [check] %}


{% endif %}

For example, this can be useful if you'd like a question label to be omitted from the document, if the associated question isn't answered. 

{% if fields.Name %} My name is {{fields.Name}}. {% endif %}


{% if fields.Name %} 
My name is {{fields.Name}}.
{% endif %}

In either case, if an answer to {{fields.Name}}  is not present, the section My name is {{fields.Name}}. will not be added to the document.

Available Functions and Operators:

  • use just the variable to check if it exists.

{% if fields.Name %} My name is {{fields.Name}}. {% endif %}

  • use == to check if it matches some value

{% if fields.Question == "yes" %} This answer is true. {% endif %}

  • use != to check that it doesn't match a value

{% if fields.Quality != "Great" %} 
Quality was not perfect & needs to be redone.
{% endif %}

  • use >, >=, <, <= to compare numbers

{% if fields.Age < 18 %} You are underage! {% endif %}

  • use contains to check if a string is included in the value.

    This should be used to check for a specific option in a Multi-Answer Select Question.

{% if fields.Multi_Select contains "Option 1" %} 
This includes Option 1.  {% endif %}

  • use == when checking for more than one option answered in a Multi-Answer Select Question. Separate the options with commas and combine the answers within quotes.

{% if fields.Question == "Option 1,Option 2,Option 3" %} ALL OF THE ABOVE! {% endif %}

Note: To check if a Multi-Answer Select Question does not contain an option, this will need to be checked in the Mobile Form first.

Add a Calculated Question that checks if the Multi-Select question contains the value.

For example:
IF(CONTAINS(Multi_Select_Question,"Option A"),"contains Option A", "does not contain Option A")

You can then use this new Calculated Question placeholder in your template, to conditionally show data based on "does not contain Option A".

{% if fields.Calculated_Question == "does not contain Option A" %}
The Multi-Select Question doesn't contain the option "Option A"!
{% endif %}

  • use boolean operators and and or

{% if fields.Name != "Tom" or fields.Name == null %} 

Oh dear! You are not Tom.

{% endif %}

Note on null: You can also use null to check if a question is blank.

{% if fields.Age >= 30 and fields.Age <= 60 %} 

You're 30-60 years old and get a discount!

{% endif %}


  • Quotation marks are required around text values you wish to compare - e.g.  {% if fields.Name == "Bob" %}

  • Select Options must be written exactly the same as the mobile forms' options and are case-sensitive.

  • Numbers do not require quotation marks - e.g.  {% if fields.rating == 10 %}

  • Yes/No Questions should be compared to "yes" and "no" - e.g. {% if fields.Yes_No_Question == "yes" %}

  • Case Sensitivity must be followed when comparing to text.

  • For steps to obtaining valid placeholders in for your form, please have a look at this article.

Other useful examples:


You can also use if statements across table rows. To do this you just put the start of the if statement in the first column cell and the {% endif %} in the last cell.

e.g. If you had a row of data about our ship that was checked - to hide the whole row if the data is missing you would put {% if fields.ShipChecked %} in the first cell of the row and then the {% endif %} in the last cell of the row.

If {{fields.ShipChecked}} doesn't have a value, the entire row will not be placed in the document.


Just like text and tables, you can also use if statements to conditionally show images.
For example, after selecting the name of a client, the associated client's logo can be shown.
In the example template below are 2 potential client logos. 

Blank Spaces

If your template has many if statements, you may see unwanted blank space in your report when some if statements are not active.

Placing the previous {% endif %} and next 'if statement start' right next to each other will eliminate unwanted space in your report, as the new line spaces are also considered conditional data inside the if statement.

{% if fields.Name %} My name is {{fields.Name}}. 

{% endif %}{% if fields.Question == "yes" %} This answer is true. {% endif %}

Repeat Groups:

To conditionally show an entire Repeat Group, use fields. and your Repeat Group name in the if statement.

To conditionally show individual Repeat Group items using an IF statement

(Case sensitive)

{%for products_used_item in fields.Products_Used%}

{% if products_used_item.Product == "Red" %} "Paint House Red" {% endif %}

{% if products_used_item.Product == "Blue" %} "Paint House Blue" {% endif %}


Custom Destination Email Subject & Body:

If you would like your Email destination to reflect information from your form, you can use IF statements in the Custom Subject and Custom Body fields within your destination.

Destination Fields:

Email Output (PDF):

For the basics on custom templating, check our this article.

If you have any questions or comments please send us a message at support@devicemagic.com.

Did this answer your question?