Using fields related to the target as javascript variables

Avatar

Avatar

ombelinel780536

Avatar

ombelinel780536

ombelinel780536

09-08-2018

Hello !

I would like to create a workflow for reporting purposes, that would automatically use data relative to the last sent deliveries as an input to formulate queries and collect some data (tracking logs for example).

I'm able to generate the query to obtain those deliveries, and I added an enrichment with the delivery code. I would now like to create javascript variables using the values in the "Delivery code" column.

How could I proceed to create and use those variables ?

Regards,

Ombeline

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Vapsy

Employee

Avatar

Vapsy

Employee

Vapsy
Employee

09-08-2018

Hi ombelinel78053619,

So I've used a simple query which I'm sure you can change as per your requirement1545627_pastedImage_2.png

Then I'm fetching the delivery code in Enrichment.

1545626_pastedImage_1.png

If you then see the schema of outbound transition it can be reached via schema temp:enrich. Please check in your case as well.

1545628_pastedImage_3.png

The add a JS code activity use the following code

1545775_pastedImage_4.png

var query = xtk.queryDef.create(

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

    <select>

      <node expr="@deliveryCode"/>  

    </select>

  </queryDef>);

var results = query.ExecuteQuery();

for each (var result in results) {

  logInfo(result.@deliveryCode);

}

I'm looping through the code to print them in the logs but you can modify the code to use in your setup.

Regards,
Vipul

Answers (1)

Answers (1)

Avatar

Avatar

ombelinel780536

Avatar

ombelinel780536

ombelinel780536

10-08-2018

Thank you very much for your help Vipul !

I have used your code (just changing the variable name to resultsCrdrn). I just would like to know how to access the variable created in this query:

1545799_pastedImage_0.png

1545947_pastedImage_1.png

The idea would be to use Crdrn as a list, with the different delivery codes, so that I can select everyone who has been targeted with a delivery which is in the variable resultsCrdrn.

Could you please explain how to proceed ?

Thanks again,

Ombeline