cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The PTC Community email address has changed to community-mailer@ptc.com. Learn more.

Nested if-then-else statements in MS Word export templates

Nested if-then-else statements in MS Word export templates

It is not possible to nest if-then-else statements in the Word export templates:

 

<% if ConditionA %>
  <% if ConditionB %>
  <% else %>
  <% endif %>
<% else %>
  <% if ConditionC %>
  <% else %>
  <% endif %>
<% endif %>

 

 

According to CS89313 the statements can be rewritten (with AND condition), but that would create a huge number of statements, when using several conditions:

 

<% if (ConditionA) AND (ConditionB) %>
<% elseif ConditionA %>
<% elseif ConditionC %>
<% else %>
<% endif %>

 

My intentation was to check for empty fields and the apply different formatting in Word. But that would mean to check lots of combinations of fields with AND conditions resulting in a hugh template. The nesting of the statements would solve that problem. Actually I was very surprised, that such basic progamming techniques are not possible.

1 Comment
bcollins-2
6-Contributor

A more thorough explanation of how to use this format would be nice too. There are so many things not explained by the documentation.