About get the result of Query Activity from JavaScript Activity in a workflow | Community
Skip to main content
Level 2
June 7, 2017
Solved

About get the result of Query Activity from JavaScript Activity in a workflow

  • June 7, 2017
  • 4 replies
  • 11364 views

Hi

I created a workflow in Adobe Campaign as the follow

Start -> Query(query some recipients) -> JavaScript -> End

I query some recipients in the Query Activity, I can't find the way to get the result in the next JavaScript Activity.

Would you like to tell me how to do that.

Best regards

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 david--garcia

tumuzhuanjia

This is possible, by reading the temporary table created to hold the query data. (https://db.tt/aiCRLu3a66 )

  1. Add a Query and target recipient table
    •     Add complementary data (this is what you can use to query in the js activity and do stuff with it) https://db.tt/Ps2IRqkyil
  1. Add Js Activity with the following code and execute the workflow.

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);

var query = xtk.queryDef.create(

  <queryDef schema={vars.targetSchema} operation="select">

    <select>

      <node expr="@email"/>

    </select>

  </queryDef>

);

result = query.ExecuteQuery();

for each (var e in result) {

logInfo(e.@email);

}

4 replies

vraghav
Adobe Employee
Adobe Employee
June 8, 2017

Hi tumuzhuanjia ,

You can achieve this by using queryDef construct inside JavaScript activity. From the outgoing transition of query activity find out the schema name and then use in queryDef for reading your data.

An example of it can be found on the link Re: Update instance variable with target data field.

Hope it helps.

Regards,

Vipul

Amit_Kumar
Level 10
June 8, 2017

Hi,

Accessing query data in JS activity is available for Reports and web applications so if you need that Read below:

This will be available in the CTX context and you can access it like ctx.query.recipient where query is the storage path of the query.

It's not available for campaign workflows because there you have some much flexibility to do everything without js so as a product feature in campaign workflow you don't have a storage path for queries.

refer to the attachment.

Regards,

Amit

david--garcia
david--garciaAccepted solution
Level 10
June 9, 2017

tumuzhuanjia

This is possible, by reading the temporary table created to hold the query data. (https://db.tt/aiCRLu3a66 )

  1. Add a Query and target recipient table
    •     Add complementary data (this is what you can use to query in the js activity and do stuff with it) https://db.tt/Ps2IRqkyil
  1. Add Js Activity with the following code and execute the workflow.

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);

var query = xtk.queryDef.create(

  <queryDef schema={vars.targetSchema} operation="select">

    <select>

      <node expr="@email"/>

    </select>

  </queryDef>

);

result = query.ExecuteQuery();

for each (var e in result) {

logInfo(e.@email);

}

RaulOcana
Level 3
November 13, 2019

Hi,

Can this be done with SQL-type-of query? I need to use Regular Expressions...

Thank you!