Skip to main content
Luca_Lattarini
Level 9
Feb 16, 2022 2:21 AM UTC
Solved

Send Email with dynamic table

Hello guys,

I am trying to send an email with dynamic row by using the code below but I am getting the error xtk not defined. Do you know which library shall i  use? Any suggestion?

Thanks

Luca

 

<%

       
      var query = xtk.queryDef.create(
      <queryDef schema="ssg:purchase" operation="select"  distinct="true">
      <select>
      <node expr="@code"/>
      <node expr="@desc"/>
      
      </select>
      </queryDef>
      );
      
      var resultSet = query.ExecuteQuery();
    var res = new XML(resultSet);

    
  
    var line = 1;
    
    for each (var row in res) { 
             
     <dynamic row table> 

      }
  

%>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
DavidKangni
DavidKangniAccepted solution
Adobe Champion and Community Advisor
Feb 16, 2022 1:52 PM UTC

try this 

 

<TABLE>
  <TBODY>
  <TR>
    <TH align=left>Code</TH>
    <TH>Description</TH></TR><%

var query = xtk.queryDef.create(
      <queryDef schema="ssg:purchase" operation="select" distinct="true">
        <select>  
          <node expr="@code" alias="code"/>  
          <node expr="@desc" alias="desc"/> 
        </select> 
      </queryDef>
    ).ExecuteQuery();
    for each (var record in query )
    {
      vars.code=record.code;
      vars.desc=record.desc;
%> 
  <TR>
    <TD><%= vars.code %></TD>
    <TD><%= vars.desc %></TD></TR><%
}
%> </TBODY></TABLE>

Thanks,

David

David Kangni

6 replies

Amine_Abedour
Community Advisor and User Group Leader
Community Advisor and User Group Leader
Feb 16, 2022 10:42 AM UTC

Hello @luca_lattarini,

 

You can not use querydef in your email. However you can achieve what you are trying to do by using the same method explained here.

 

Br

 

Amine

Translate
Amine ABEDOUR
DavidKangni
Adobe Champion and Community Advisor
DavidKangniAdobe Champion and Community AdvisorAccepted solution
Adobe Champion and Community Advisor
Feb 16, 2022 1:52 PM UTC

try this 

 

<TABLE>
  <TBODY>
  <TR>
    <TH align=left>Code</TH>
    <TH>Description</TH></TR><%

var query = xtk.queryDef.create(
      <queryDef schema="ssg:purchase" operation="select" distinct="true">
        <select>  
          <node expr="@code" alias="code"/>  
          <node expr="@desc" alias="desc"/> 
        </select> 
      </queryDef>
    ).ExecuteQuery();
    for each (var record in query )
    {
      vars.code=record.code;
      vars.desc=record.desc;
%> 
  <TR>
    <TD><%= vars.code %></TD>
    <TD><%= vars.desc %></TD></TR><%
}
%> </TBODY></TABLE>

Thanks,

David

Translate
David Kangni
Sukrity_Wadhwa
Level 4
Mar 3, 2022 12:09 PM UTC

Hi @luca_lattarini,

Were you able to resolve this query with the help of any of the given solutions or do you still need more help here? Do let us know.
Thanks!

Translate
Sukrity Wadhwa
Luca_Lattarini
Level 9
Mar 14, 2022 8:29 AM UTC

Hello Sukrity_Wadhwa,

No I still have issue. By Considering that I want to send out a summery delivery table with Open, clicks etc,  I created a simple workflow as showed below

The JS code has the query 

 

var eQuery = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation="select">
<select>
<node expr="@id"/>
<node expr="@internalName"/>
<node expr="@label"/>
<node expr="@state"/>
<node expr="@lastModified"/>
<node expr="[scheduling/@contactDate]"/>
<node expr="[scheduling/@validityDate]"/>
<node expr="[properties/@toDeliver]"/>
<node alias="@_progression" expr="Percent([indicators/@processed], [properties/@toDeliver])"/>
<node expr="[indicators/@successRatio]"/>
<node alias="@dataQuality" expr="Percent([indicators/@unknownUser], [indicators/@processed]) + Percent([indicators/@mailboxFull], [indicators/@processed]) + Percent([indicators/@invalidDomain], [indicators/@processed])"/>
<node alias="@reputation" expr="Percent([indicators/@refused], [indicators/@processed]) + Percent([indicators/@unreachable], [indicators/@processed])"/>
<node alias="@optOut" expr="[indicators/@optOut]"/>
<node alias="@optOutRatio" expr="[indicators/@optOutRatio]"/>
<node alias="@opens" expr="[indicators/@totalRecipientOpen]"/>
<node alias="@clickRatio" expr="[indicators/@recipientClickRatio]"/>
<node alias="@clicks" expr="[indicators/@recipientClick]"/>
<node alias="@errors" expr="[indicators/@error]"/>
<node alias="@errorRatio" expr="[indicators/@errorRatio]"/>
</select>


</queryDef>).ExecuteQuery();


instance.vars.deliveries=eQuery; // assign query result to instance.vars.deliveries;

in the Alert I have the code below

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ""><HTML><HEAD>
</HEAD>
<BODY><%


var deliveries = new XML(instance.vars.deliveries);

 


for each (var delivery in deliveries )
{
vars.code=delivery.@label;

%><%


}
%>
<TABLE>
<TBODY>
<TR>
<TH align="left">Code</TH>
</TR>
<TR>

<TD><%= vars.code %></TD></TR></TBODY></TABLE></BODY></HTML>

 

if I try to run the workflow I have the error below

any idea?

 

Translate
Sukrity_Wadhwa
Level 4
Mar 14, 2022 12:08 PM UTC

Thanks @luca_lattarini for sharing this. I will escalate your issue among our SMEs.

Translate
Sukrity Wadhwa