<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Using if else condition in docx template</title><link>https://community.appian.com/discussions/f/plug-ins/40448/using-if-else-condition-in-docx-template</link><description>Hi Champs, 
 I am using docx from dynamic template smart service to create dynamic document. It&amp;#39;s working with simple table. Now I want to try with if else condition in my template. I am not sure the syntax to use to work with it.Can someone please guide</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154680?ContentTypeID=1</link><pubDate>Mon, 25 May 2026 16:13:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:611569dc-f4d4-4be8-b7d0-e0646b546cc0</guid><dc:creator>gayathris876948</dc:creator><description>&lt;p&gt;Try &amp;lt;#if r.age?number &amp;gt; 30&amp;gt;&lt;br /&gt; ...&lt;br /&gt;&amp;lt;/#if&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154679?ContentTypeID=1</link><pubDate>Mon, 25 May 2026 13:09:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4641fdde-c058-46e7-9dc4-e74c6db8000a</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Try this once&lt;br /&gt;&amp;laquo;[#if r.@ageAbove30?string == 'true']&amp;raquo;Above 30&amp;laquo;[#else]&amp;raquo;30 or below&amp;laquo;[/#if]&amp;raquo;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154668?ContentTypeID=1</link><pubDate>Mon, 25 May 2026 04:44:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bbec5b82-454c-4002-b960-a9c12113bcd4</guid><dc:creator>ghanashyam905071</dc:creator><description>&lt;p&gt;I tried the same&amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;laquo;[#if r.ageAbove30 == 'true']&amp;raquo;Above 30&amp;laquo;[#else]&amp;raquo;30 or below&amp;laquo;[/#if]&amp;raquo; but r.ageAbove30 is not taking as a boolean ; rather as an extended node+sequence+string and due to the same it&amp;#39;s giving the error saying can&amp;#39;t compare value of these types.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154660?ContentTypeID=1</link><pubDate>Sat, 23 May 2026 04:32:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:33309483-c0e2-4b4c-8a55-b02ac6d568f3</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Pre-compute the flag in expression (ageAbove30: if(r.age &amp;gt; 30, &amp;quot;true&amp;quot;, &amp;quot;false&amp;quot;)) and pass it in your XML/dictionary.&lt;br /&gt;In the template, use: &amp;laquo;[#if r.ageAbove30 == 'true']&amp;raquo;Above 30&amp;laquo;[#else]&amp;raquo;30 or below&amp;laquo;[/#if]&amp;raquo;&lt;br /&gt;&lt;br /&gt;Each [#if], [#else], [/#if] must be its own separate MergeField.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154658?ContentTypeID=1</link><pubDate>Fri, 22 May 2026 18:14:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0a503ecd-0cf5-48c7-b755-c851fa911904</guid><dc:creator>ghanashyam905071</dc:creator><description>&lt;p&gt;I tried with the if syntax given as a separate merge field as sugegsted.. but during run time when I am using r.age &amp;gt; 30, it&amp;#39;s throwing exception saying left hand operator is an extended node+sequence+hash+string&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using if else condition in docx template</title><link>https://community.appian.com/thread/154657?ContentTypeID=1</link><pubDate>Fri, 22 May 2026 17:36:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e6362642-8bd7-4995-a625-b9d1cd228811</guid><dc:creator>gayathris876948</dc:creator><description>&lt;p&gt;Hi Shyam,&lt;/p&gt;
&lt;p&gt;Since your simple table is already working, here&amp;rsquo;s a complete guide for the next level &amp;mdash; dynamic table rows, conditional rows, and lists &amp;mdash; all using FreeMarker inside MergeFields.&lt;/p&gt;
&lt;p&gt;1. Loop through a list to generate table rows ([#list])&lt;/p&gt;
&lt;p&gt;In your Word template, create a table with a header row and one data row. Put the loop directives in that data row as MergeFields:&lt;/p&gt;
&lt;p&gt;|# |Name |Status |&lt;br /&gt;|-------------------------------------|-----------------|-------------------|&lt;br /&gt;|`&amp;laquo;[#list doc.project.items as item]&amp;raquo;`| | |&lt;br /&gt;|`&amp;laquo;${item.@id}&amp;raquo;` |`&amp;laquo;${item.@name}&amp;raquo;`|`&amp;laquo;${item.@status}&amp;raquo;`|&lt;br /&gt;|`&amp;laquo;[/#list]&amp;raquo;` | | |&lt;/p&gt;
&lt;p&gt;Each directive ([#list], [/#list]) must be its own separate MergeField in the cell. When looping over a list of XML elements, you don&amp;rsquo;t need a counter &amp;mdash; just refer to each field using item.@fieldName syntax. ￼&lt;/p&gt;
&lt;p&gt;2. Condition inside a table cell&lt;/p&gt;
&lt;p&gt;To show different values per cell based on a condition:&lt;/p&gt;
&lt;p&gt;&amp;laquo;[#if item.@status == 'APPROVED']&amp;raquo;Approved&amp;laquo;[#else]&amp;raquo;Pending&amp;laquo;[/#if]&amp;raquo;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Each part &amp;mdash; the [#if ...], the text content, the [#else], and the [/#if] &amp;mdash; must be placed as separate MergeFields. The text between them is plain Word text with formatting applied normally. ￼&lt;/p&gt;
&lt;p&gt;3. Show/hide an entire table row conditionally&lt;/p&gt;
&lt;p&gt;Put the [#if] MergeField in the first cell of the row and [/#if] in the last cell:&lt;/p&gt;
&lt;p&gt;| &amp;laquo;[#if item.@type == 'INTERNAL']&amp;raquo; | &amp;laquo;${item.@name}&amp;raquo; | &amp;laquo;${item.@value}&amp;raquo; | &amp;laquo;[/#if]&amp;raquo; |&lt;/p&gt;
&lt;p&gt;This hides the entire row when the condition is false.&lt;/p&gt;
&lt;p&gt;4. Null / empty check for table cells&lt;/p&gt;
&lt;p&gt;Use ?has_content to safely handle empty values:&lt;/p&gt;
&lt;p&gt;&amp;laquo;[#if item.@remarks?has_content]&amp;raquo;&amp;laquo;${item.@remarks}&amp;raquo;&amp;laquo;[#else]&amp;raquo;-&amp;laquo;[/#if]&amp;raquo;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;5. Row number / counter inside a loop&lt;/p&gt;
&lt;p&gt;FreeMarker provides a built-in counter variable item_index (0-based):&lt;/p&gt;
&lt;p&gt;&amp;laquo;${item_index + 1}&amp;raquo;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;6. Notes&lt;/p&gt;
&lt;p&gt;&amp;bull; Every [#list], [/#list], [#if], [#else], [/#if] must be in its own MergeField &amp;mdash; never mixed with text.&lt;br /&gt; &amp;bull; Use single quotes for string comparisons to avoid Word escaping double quotes to \&amp;quot;.&lt;br /&gt; &amp;bull; Check Appian System Logs for the full FreeMarker error &amp;mdash; it pinpoints the exact line and column.&lt;/p&gt;
&lt;p&gt;Hope this helps!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>