I am trying to define a variable (or query def) in a JS alert and then call the variable or item in an alert activity. I am aware of the current stock method using:
<% var itemsXML = new XML(vars.itemsXMLString)
for each (var item in itemsXML){
%>
However, i don't want to call every instance of the particular field / node. I have some fields i want to output into a table and some where i only want a single instance of the field. Below is my current setup:
JS Activity -- For the nodes "Web Registations" and "Appt Sum" i only want to include the first row. For all the other nodes i want to include every occurence.
var query = xtk.queryDef.create (
<queryDef schema= "temp:union" operation="select">
<select>
<node expr="CreationDate" />
<node expr="@appointment"/>
<node expr="Registrations"/>
<node expr="Origin"/>
<node expr="WebRegistrations"/>
<node expr="ApptSum"/>
</select>
<orderBy >
<node expr="CreationDate" sortDesc="true"/>
</orderBy >
</queryDef>)
var itemsXML = query.ExecuteQuery();
vars.itemsXMLString = itemsXML.toXMLString()
instance.vars.WebRegistrations=[INSERT WF FIELD HERE]
ALERT ACTIVITY
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE>
table {
border-collapse: separate;
border-spacing: 0;
color: #4a4a4d;
font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif;
}
th,
.title {
border-spacing: 0;
color: #4a4a4d;
font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
}
}
td {
padding: 10px 15px;
vertical-align: left;
}
thead {
background: #808080;
color: #fff;
}
th:first-child {
text-align: left;
}
tbody tr:nth-child(even) {
background: #f0f0f2;
}
td {
border-bottom: 1px solid #cecfd5;
border-right: 1px solid #cecfd5;
border-top: 1px solid #cecfd5;
border-left: 1px solid #cecfd5;
}
td:first-child {
border-left: 1px solid #cecfd5;
}
tfoot {
text-align: right;
}
tfoot tr:last-child {
background: #f0f0f2;
}
</STYLE>
<META name=GENERATOR content="MSHTML 11.00.10570.1001"></HEAD>
<BODY>
<P><STRONG>Daily Campaign/Delivery Details for <%= formatDate(new Date(), "%2M/%2D/%2Y") %></STRONG>
<DIV class=Title>
<P># of campaigns: <%= instance.vars.WebRegistrations %></P></DIV><BR>
<TABLE id=t02>
<TBODY>
<THEAD>
<TR>
<TD>Creation Date</TD>
<TD>Origin</TD>
<TD>Appointment</TD>
<TD>Registrations</TD>
</TR></THEAD><%
var itemsXML = new XML(vars.itemsXMLString)
for each (var item in itemsXML){
%>
<TBODY>
<TR>
<TD><%= formatDate(item.CreationDate, "%A %D %B %4Y") %></TD>
<TD><%= item.Origin %></TD>
<TD><%= item.@appointment %></TD>
<TD><%= item.Registrations %></TD></TR></TBODY><%
} %> </TBODY></TABLE><BR><BR>
<P></P></BODY></HTML>