Leiste mit Community-Erfolgen erweitern.

GELÖST

Help: Adding work table content into a workflow alert

Avatar

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 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Level 10
5 Antworten

Avatar

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

Avatar

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.

Avatar

Level 2

bump

Avatar

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.

Avatar

Korrekte Antwort von
Level 10

Hi Wesp,

See also my answer in this post:

How to Personalize the Workflow content into Alert Activity.

Regards
J-Serge