Repeating section as html table in mail


Badge +9

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


30 replies

Badge +9

by xml tranformation html is generated, e.g. <td>  or <table> tag.

There css inline style can be inserted, e.g.

<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;">

 

more infos on e.g. https://www.w3schools.com/css/css_howto.asp

Badge

how to define workflow variable to be like that? i have no idea

Badge +1

Sorry, I know I am several years late to the party, but...I found this nifty little List View for repeating sections from @eharris04  (https://community.nintex.com/t5/Community-Blogs/Create-Parent-Child-items-using-this-Nintex-forms-workflow-with/ba-p/76650). The problem is, XSLT transformation requires the repeating section to be connected. The Parent/Child workflow requires the repeating section to NOT be connected.

 

I really like both and am trying to figure out how to combine them so I can use both workflows on the same SP list. So far no luck. Any ideas on a work-around?

Badge +1

Never mind - color me dunce but I have seen the obvious:-)

Badge +2
Hi Manfred,
I have a requirement to send separate email based on a cost centre with repeating section data in HTML table with data only relevant to that cost centre?
In your post in July last year you had "see . There you will find an example how to filter items," The link appears to be missing. Scott

Reply