Help: Adding work table content into a workflow alert | Community
Skip to main content
September 26, 2019
Solved

Help: Adding work table content into a workflow alert

  • September 26, 2019
  • 5 replies
  • 7439 views

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!

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 %> <%
    } 
    %>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jean-Serge_Biro

Hi Wesp,

See also my answer in this post:

How to Personalize the Workflow content into Alert Activity.

Regards
J-Serge

5 replies

Jonathon_wodnicki
Community Advisor
Community Advisor
September 26, 2019

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

wpomeroyAuthor
September 26, 2019

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.

wpomeroyAuthor
September 30, 2019

bump

priyal_b
October 3, 2019

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
Jean-Serge_BiroAccepted solution
October 3, 2019

Hi Wesp,

See also my answer in this post:

How to Personalize the Workflow content into Alert Activity.

Regards
J-Serge