Using If Tagging Element

The IF tagging element can be used to hide or display the content based on some conditional expression. If its expression evaluates to true, the content will be displayed, if it evaluates to false, however, it will not be included in the final document.

Typical scenarios are:

  1. Hide or display some text or part of a document
  2. Hide or display a tagging element
  3. Hide or display a row in a MS Word table
  4. Hide or display the entire section in MS Word

Hide or display some part of a document

The easiest way to use conditional content is to first write the content and then select it and click the If tagging element on the Docentric AX ribbon to wrap selected content into conditional content. Then add the conditional expression.

The example in the image below shows the Sales invoice where we want to hide the tax information, if the SalesInvoiceLines_Tax/@ShowTaxTrans is true.

Explanation of steps:

  1. It is always recommended to have paragraph marks turned on. We want the two paragraphs and then the whole table with tax information to be part of conditional content.
  2. Having this content selected, we click the If tagging element button on the Docentric AX ribbon.
  3. The Properties of the If tagging element contain the conditional expression.

Hide or display a tagging element

Sometimes we want to display some tagging element conditionally (e.g. FIELD, SUMMARY FIELD, IMAGE). The image below shows how to hide the field if the result is less than zero.

This time we will hide the display of the PurchOrderHeader/@ConfirmingPOMessage Field tagging element on the Purchase order, when the value is not entered.

Step by step explanation to the image above:

  1. Select the field in the Element Tree.
  2. Click on the Field tab in the document.
  3. Click the If tagging element.

Now we have to open the XPath editor where we will be able to insert the expression.

Step by step explanation to the image above:

  1. Click on the newly inserted If tagging element in the Element Tree pane.
  2. Click on the drop down button to open the XPath line editor.
  3. Click on the pencil button to open the XPath dialog window.

Now we can enter the XPath expression in the XPath Editor, which will determine if the conditional content will be displayed or not. We can choose from different Binding Source options and then select the XML element path and enter the expression. In our case we are checking if the field is not empty (we are using single quotes for string values). If it is not, this expression will evaluate to true and the field will be displayed. Otherwise it will be hidden.

Inverting the expression value

Sometimes it is more convenient to write an expression that yields the opposite value and then simply invert this value. In our example we could enter the expression PurchOrderHeader/@ConfirmingPOMessage = " which will evaluate to false if it will contain a value. By inversion we invert the return value to true which is what we need. The image below shows how the inverted value can be turned on.

Hide or display a row in a MS Word table

A very useful feature of the If tagging element is to be able to hide an entire row in a table. Let’s see that on the example of the additional data on the Purchase order lines. We want to hide the entire additional data lines if there is no content.

To do this we select the entire line in the table, as shown in the image below.

The entire set of lines, marked by (1) are part of the List tagging element. We now select one row by clicking on the space just before that table row as indicated by the arrow (2). This action selects the entire table row. Next we click the If tagging element button (3) end enter the expression as explained earlier. At runtime, this entire row will not be displayed in the table if the expression will evaluate to false.


In some cases we cannot use the If tagging element. For example, we cannot use it to show/hide a row in a table if the table has merged rows in one or more columns and not all merged rows are included in our selection.

We also cannot use the If tagging element to show/hide columns in a table. It is possible, however, to use Visual Format properties to achieve that.

See also

Using Visual Format Override >>