Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Seancy
Contributor II
Contributor II

Email body can't display an array (straight table output) in body of email

With the output from a straight table, you can see in the pic1 below how I set up the sent email.  However, Qlik will not give an output, see pic2.  Then I put ion this HTML script, it's below the pics, and it will only return the 1st row from the Get Straight table output array.  If I change the index from [0] to [*] it fails as well.  I am not an html master by any stretch and even utilized Chat GPT which recognized an issue with the loop, but it failed multiple times (it's pasted below the 1st HTML section) in producing script that would work. Also there was mention of a template engine that Qlik uses, anyone know which one it is?  Anyone have any thoughts on how to fix this?

pic1

Seancy_0-1744380121555.png 

pic2

Seancy_1-1744380226074.png

 

 

HTML produces 1 row only, changing index to [*] fails:

<!DOCTYPE html>
<html>
  <body style="font-family: Arial, sans-serif; font-size: 14px; color: #333;">
    <p>Dear Team,</p>

    <p>Please find below the latest Purchase Order receipt details:</p>

    <table cellpadding="8" cellspacing="0" border="1" style="border-collapse: collapse; width: 100%; text-align: left;">
      <thead style="background-color: #f2f2f2;">
        <tr>
          <th>PO Received At</th>
          <th>PO Key</th>
          <th>Product Number</th>
          <th>Product</th>
          <th>Quantity Received</th>
          <th>CSR Representative</th>
          <th>CSR Email</th>
        </tr>
      </thead>
      <tbody>
        <!-- Repeat this row for each item in GetStraightTableData4 -->
        <!-- Example row starts -->
        <tr>
          <td>{ $.GetStraightTableData4[0].POReceivedAt }</td>
          <td>{ $.GetStraightTableData4[0].POKey }</td>
          <td>{ $.GetStraightTableData4[0].ProductNum }</td>
          <td>{ $.GetStraightTableData4[0].Product }</td>
          <td>{ $.GetStraightTableData4[0].Qty_Received] }</td>
          <td>{ $.GetStraightTableData4[0].CSR_Rep }</td>
          <td><a href="mailto:{ $.GetStraightTableData4[0].CSR_Email }">{ $.GetStraightTableData4[0].CSR_Email }</a></td>
        </tr>
        <!-- Example row ends -->
        <!-- Repeat the above row for each index [1], [2], etc., or use a loop if supported -->
      </tbody>
    </table>

    <p>If you have any questions, please contact your CSR directly using the details provided.</p>

    <p>Best regards,<br>Your Operations Team</p>
  </body>
</html>
 
 
HTML loop that fails:
 

<!DOCTYPE html>
<html>
<body style="font-family: Arial, sans-serif; font-size: 14px; color: #333;">
<p>Dear Team,</p>

<p>Please find below the latest Purchase Order receipt details:</p>

<table cellpadding="8" cellspacing="0" border="1" style="border-collapse: collapse; width: 100%; text-align: left;">
<thead style="background-color: #f2f2f2;">
<tr>
<th>PO Received At</th>
<th>PO Key</th>
<th>Product Number</th>
<th>Product</th>
<th>Quantity Received</th>
<th>CSR Representative</th>
<th>CSR Email</th>
</tr>
</thead>
<tbody>
{% for record in GetStraightTableData4 %}
<tr>
<td>{{ record.POReceivedAt }}</td>
<td>{{ record['%POKey'] }}</td>
<td>{{ record.ProductNum }}</td>
<td>{{ record.Product }}</td>
<td>{{ record['Sum(QtyReceived)'] }}</td>
<td>{{ record.CSR_Rep }}</td>
<td><a href="mailto:{{ record.CSR_Email }}">{{ record.CSR_Email }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>

Labels (3)
2 Replies
Shai_E
Support
Support

Hi @Seancy 

Let me see if i can do a small example.

Shai_E
Support
Support

Hi @Seancy 

You can try the following example and work on it change it to the way you like.
I assume there is an even better way to do this, but i did it on the fly.

It makes use of the custom code block, it uses a little javascript to create a string html representation of the table rows and their values.

Not super scalable depending on the number of columns you have.

Best Regards