Including Item lists in e-mails

Facebooktwittergoogle_pluspinterestlinkedinmail
Applies to version 8.3 and above; Authors: Artur Chac and Kamil Nędza

How to add Item lists to e-mail messages?

Having actions that send the contents of an item list via email is useful in certain types of workflows (e.g. requisition workflows). Normal form fields can be included in e-mails simply by using their corresponding variables. Item lists can also be included easily, but require a little bit of preparation:

  1. Build an HTML fragment.
  2. Include variables referencing the relevant database columns.
  3. Paste the HTML fragment into the ‘Message body’ section of a ‘Send a custom e-mail’ action.

 

To continue, you will need the following things:

  • The ID of the Item list you wish to send
  • The database column addresses of your Item list’s columns
  • Basic understanding of HTML tables

 

Sample configuration using a ‘Requisition’ Item list

My ‘Requisition’ Item list as seen on the workflow form:

 

My ‘Requisition’ Item list as seen in WEBCON BPS Designer Studio (the Item list ID has been marked):

 

Details of the ‘Name’ column (database column address has been marked):

 

Details of the ‘Category’ column (database column address has been marked):

 

Details of the ‘Value’ column (database column address has been marked):

 

1. First, we need to build a basic HTML table; either manually or by using any available editor. You can also use the following code as a base for your own table.

 

HTML code:

<TABLE style=”BORDER-TOP-COLOR: gray; BORDER-LEFT-COLOR: gray; BORDER-BOTTOM-COLOR: gray; MARGIN-TOP: 5px; BORDER-RIGHT-COLOR: gray” cellSpacing=0 cellPadding=4 width=460 border=1>

<TBODY>

<TR style=”FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR: black”>

<TD>Name</TD>

<TD>Category</TD>

<TD>Value</TD>

</TR>

<TR style=”FONT-WEIGHT: bold”>

<TD></TD>

<TD>Total:</TD>

<TD>zł</TD></TR>

</TBODY>

</TABLE>

 

What the table looks like so far:

 

2. Next we need to add variables that reference our item list (marked in red) and its columns (marked in green) to the HTML table.

 

<TABLE style=”BORDER-TOP-COLOR: gray; BORDER-LEFT-COLOR: gray; BORDER-BOTTOM-COLOR: gray; MARGIN-TOP: 5px; BORDER-RIGHT-COLOR: gray” cellSpacing=0 cellPadding=4 width=460 border=1>

<TBODY>

<TR style=”FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR: black”>

<TD>Name</TD>

<TD>Category</TD>

<TD>Value</TD>

</TR>

<!– Open section listing data from ‘Requisition’ Item list; ID of ‘Requisition’ Item list –>

{SUBELEMROWTEMPLATE:1535}

<TR>

<TD>{DET_Att1}</TD>

<TD>{DET_Att2}</TD>

<TD>{DET_Value1}</TD></TR>

<!– Close section listing data from ‘Requisition’ Item list –>

{/SUBELEMROWTEMPLATE}

<!–  Open footer section of ‘Requisition’ Item list; ID of ‘Requisition’ Item list –>

{SUBELEMFOOTERTEMPLATE:1535}

<TR style=”FONT-WEIGHT: bold”>

<TD></TD>

<TD>Total:</TD>

<TD>{DET_Value1} zł</TD></TR>

<!– Close footer section of ‘Requisition’ Item list –>

{/SUBELEMFOOTERTEMPLATE}

</TBODY>

</TABLE>

 

Table layout:

 

3. The prepared piece of HTML code can be included in the ‘Send custom e-mail’ action configuration. Go to the ‘Message content’ tab and, switch the ‘Content’ editor to ‘HTML’ mode and paste your code in. You can preview the content by switching back to ‘Editor’ mode, or preview the entire e-mail by going to the ‘Mail preview’ tab.

 

4. Done! You can now include data from Item lists found on your workflow instances in e-mail messages sent by the system.

One thought to “Including Item lists in e-mails”

  1. The information in this article applies to one item list.
    If you need to load data from multiple item lists, I recommend using the {SUBELEMHEADERTEMPLATE} variable instead.
    The example below allows you to use two item lists
    Based on it, you can create a template for using as many item lists as you need.

    <meta name="ProgId" content="SharePoint.WebPartPage.Document" />
    <meta name="Microsoft Theme" content="Lacquer 1011, default" /><form id="form1" runat="server" />
    <b>List 1</b>
    <br />
    <table style="border-top-color: gray; border-bottom-color: gray; border-right-color: gray; border-left-color: gray" cellspacing="0" cellpadding="4" width="760" border="1">
    <tbody>
    <tr>
    {SUBELEMHEADERTEMPLATE:108}
    <th>LP</th>
    <th>text1</th>
    <th>value</th>
    <th>text2</th>
    {/SUBELEMHEADERTEMPLATE}
    {SUBELEMROWTEMPLATE:108}
    </tr>
    <tr>
    <td>{DET_LP}</td>
    <td>{DET_Att1}</td>
    <td>{DET_Value1}</td>
    <td>{DET_Att2}</td>
    </tr>
    {/SUBELEMROWTEMPLATE}
    </tbody>
    </table>
    <b>List 2</b>
    <br />
    <table style="border-top-color: gray; border-bottom-color: gray; border-right-color: gray; border-left-color: gray" cellspacing="0" cellpadding="4" width="760" border="1">
    <tbody>
    <tr>
    {SUBELEMHEADERTEMPLATE:109}
    <th>LP</th>
    <th>text1</th>
    <th>value</th>
    <th>text2</th>
    {/SUBELEMHEADERTEMPLATE}
    {SUBELEMROWTEMPLATE:109}
    </tr>
    <tr>
    <td>{DET_LP}</td>
    <td>{DET_Att1}</td>
    <td>{DET_Value1}</td>
    <td>{DET_Att2}</td>
    </tr>
    {/SUBELEMROWTEMPLATE}
    </tbody>
    </table>
    </form>

Leave a Reply

Your email address will not be published. Required fields are marked *