Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Help: Adding work table content into a workflow alert

wesp27904446
Level 2
Level 2

Hello,

I am trying to add content from my workflow into the body of an alert.  I'm using the process outlined by Adobe via inserting a javascript code activty.  The workflow appears to run but the alert is not properly populating with the data.  Below is the code i am using in the javascript activity as well as the alert. Any insight into what i'm missing here would be much appreciated!

2019-09-26 09_19_32-Adobe Campaign Classic - Client console (pomeroyw@PROD).jpg

Javascript Activity:

var query = xtk.queryDef.create( 

    <queryDef schema="temp:query2" operation="select"> 

      <select> 

       <node expr="[/@label1]"/> 

      </select> 

     </queryDef> 

  ); 

  var items = query.ExecuteQuery();

Alert:

<%

var items = new XML(instance.vars.items) for each (var item in items){ 

%>

  • <%= item.@label1 %> <%
    } 
    %>
1 Accepted Solution
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor
5 Replies
wodnicki
Community Advisor
Community Advisor

Hi,

Alerts (deliveries) don't have access to workflow's vars. You have to ship data through one of the activity's properties, usually title or message.

In the initialization script of the alert activity (under Advanced), add this:

activity.message = instance.vars.items;

And then in your alert:

<% var items = new XML(dataSource.message); ... %>

I have a library that formalizes this approach and provides a shared scope across workflows and deliveries, should be how the product works really.

Thanks,

-Jon

wesp27904446
Level 2
Level 2

Hello John,

Thank you for your help.  Would you mind providing additional clarification on the second part?  I'm unclear as to where this is pulling from or what else needs to be added here to populate with the data from the work table.  Apologies for my lack of knowledge on this.

priyal_b
Level 3
Level 3

Hi you need to add additional variables info to your JS code after - var items = query.ExecuteQuery();

------------------

for each (var row in items )

instance.vars.label= row.@label1;

------------------

then in alert use this instance var  as-  <%= instance.vars.label%>

Hope this helps.

Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor