Conditional blocks allow you to show or hide sections of the document according to conditional expressions. 

A conditional block consists of a part of a document with the following notation:

Expand to see the sample code
#{if (%{<Javascript>})}
	CONTENT
#{end}

<Javascript> is a javascript expression that should evaluate to true or false.

The code below demonstrates a working example.

Expand to see the sample code
This is the header of the document. 

#{if (%{'${IssueTypeName}'.equals('Bug')})}
This section will only be visible if the issue type of the issue is Bug
This issue is a bug created by ${AssigneeUserName} with priority ${Priority}.
#{end}

#{if (%{'${Priority}'.equals('Major')})}
This section will only be visible if the priority of the issue is major.
This issue has top priority, needs to be resolved until ${DueDate}.
#{end}

#{if (%{'${escape:Description}'.equals('')})}
This issue has no description
#{end}

#{if (%{'${escape:Description}'.length > 0})}
Issue description: ${Description}
#{end}

This is the footer of the document.  

For a working example of this functionality, check the template Sample Conditions.docx in the Template Store.

The image below demonstrates a Word template with a conditional block:

The image below demonstrates an Excel template with a conditional block:

 

  • No labels