Repeating section as html table in mail

Document created by mlauer Champion on Aug 24, 2015Last modified by mlauer Champion on Feb 7, 2016
Version 5Show Document
  • View in full screen mode

A simple way to convert Nintex Forms Repeating section XML data to a HTML table is using a XLS transformation. To do the transformation only one action is needed: Query XML.

Here is a simple example (Forms 2013, Workflow 2013). The form looks like:

 

Repeating section contains three single line controls named 'last_name', 'first_name', 'company' and is connected to workflow variable 'contacts_xml' of type 'Multiple lines of text'.

 

XML-content of contacts_xml:

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><last_name type="System.String">Lauer</last_name><first_name type="System.String">Manfred</first_name><company type="System.String">KOB</company></Item><Item><last_name type="System.String">Billing</last_name><first_name type="System.String">Emily</first_name><company type="System.String">Nintex</company></Item></Items></RepeaterData>

 

xml to html transformation is made with a Query XML action. XML source is workflow variable contacts_xml, result will be stored in workflow variable contacts_html

 

Here is complete XSLT as text:

<?xml version="1.0"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

        <!-- transform repeating section from xml to html -->

        <xsl:template match="/">

            <xsl:apply-templates />

        </xsl:template>

 

        <xsl:template match="Items">

            <table border="1" width="100%" style="border-collapse:collapse;background-color:#eee;border:1px solid;color:black;font-size:100%;font-family:arial,helvetica,sans-serif;">

                <thead>

                    <tr>

                        <td>first name</td>

                        <td>name</td>

                        <td>company</td>

                    </tr>

                </thead>

                <tbody>

                    <xsl:apply-templates />

                </tbody>

            </table>

        </xsl:template>

 

        <xsl:template match="Item">

            <tr>

                <!-- field output order -->

                <xsl:apply-templates select="first_name" />

                <xsl:apply-templates select="last_name" />

                <xsl:apply-templates select="company" />

            </tr>

        </xsl:template>

 

        <xsl:template match="first_name">

            <td>

                <xsl:value-of select="." disable-output-escaping="yes"/> </td>

        </xsl:template>

 

        <xsl:template match="last_name">

            <td>

                <xsl:value-of select="." disable-output-escaping="yes"/> </td>

        </xsl:template>

 

        <xsl:template match="company">

            <td>

                <xsl:value-of select="." disable-output-escaping="yes"/> </td>

        </xsl:template>

 

    </xsl:stylesheet>

 

To avoid problems with german Umlauten etc. output escaping has to be disabled because content of repeating section in XML is already encoded.

 

Resulting html in workflow variable contacts_html:

<table border="1" width="100%" style="border-collapse:collapse;background-color:#eee;border:1px solid;color:black;font-size:100%;font-family:arial,helvetica,sans-serif;"><thead><tr><td>first name</td><td>name</td><td>company</td></tr></thead><tbody><tr><td>Manfred</td><td>Lauer</td><td>KOB</td></tr><tr><td>Emily</td><td>Billing</td><td>Nintex</td></tr></tbody></table>

 

In Send notification action choose Rich Text and insert by reference workflow variable contacts_html:

 

Resulting mail looks like:

The look of the table can be changed by using inline css styles.

 

Example workflow is attached. Comments are welcome.

 

Manfred Lauer

 

see also XSL Transformation of repeating section to html

4 people found this helpful

Attachments

Outcomes