Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Use of variable in continuous delivery, how to do ?

Avatar

Level 2

Hi all,

I'm using continuous delivery, and I would like to personalize data in the message with variables. My data are not linked to the recipient dimension. I tried to use variable defined in the delivery (delivery properties, variables tab) but I'm not able to assign a value to my delivery variable in my workflow. I don't find the syntax to use in the initialization script of my continuous delivery.

Could someone help me with this ?

Best regards,

Celine

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello,

The error is okey

but make sure you are using the right instance variable and actually it is better to use alert activity instead of delivery.

The workflow can look like the one below:

6-12-2017 6-10-23 PM.png

where:

- query population you want report on

- java script activity where you save population from query to the instance variable

  • also you can write this code into the initialization script of the alert activity instead of having JS activity in the workflow6-12-2017 6-21-52 PM.png

- test activity is checking population count > 0 in which case it will send alert message to any operator or group

6-12-2017 6-23-48 PM.png

- alert where you loop over the population and make e.g table from it, which will be send alert to operator

6-12-2017 6-04-32 PM.png

Marcel

View solution in original post

20 Replies

Avatar

Community Advisor

Hello Celine,

you need to use enrichment to add any additional data to the recipient table and then use it as you would normally use it in the delivery. If the data are not linked you can use reconciliation tab for adding data to the pipeline.

6-12-2017 10-09-23 AM.png

6-12-2017 10-04-23 AM.png

6-12-2017 10-02-46 AM.png

BR,

Marcel

Avatar

Level 2

Hello Marcel,

Thanks for your answer, but it won't work for me. My targeting workflow works on a dimension wich is not the dimension used for the delivery, and I've no fields on which I can do a reconciliation. I would like to send an email to a particular operator with data concerning recipients that I've collected in the workflow. That's why I want to use variables and not target data.

Any idea to do that ?

(sorry for my english...)

Céline

Avatar

Community Advisor

Hello Celine,

so you have output from workflow and you want send the information in the pipeline to some operator, right?

If this is the case (hope so) you need to collect data stored in the pipeline and display them in the delivery (alert to operator).

It can be easily done by:

Either adding java script code in the activity before the delivery or you can actually paste JS code right into the alert or delivery itself.

1)

Add JS activity before delivery and check name of activity before.

var query = xtk.queryDef.create(

    <queryDef schema="query" operation="select">

      <select>

       <node expr="fields_from_select1"/>

       <node expr="fields_from_select2"/>

      </select>

     </queryDef>

  );

  instance.vars.items = query.ExecuteQuery();

EDIT:

 <queryDef schema="temp:query".....

it should be temp:activity_name

6-12-2017 2-29-56 PM.png

2) Add JS code to the delivery activity

you need to loop data saved in instance.vars.items  and display them in the email contents:

<% for each (var item in instance.vars.items){ %>

  <%=  item.field_from_select1 %>

  <%=  item.field_from_select2 %>

  <%=  item.field_from_select3 %>

<%}%>

Write JS code in the source mode

<% %>        for JS code

<%= %>        for writing JS code to the output

6-12-2017 2-36-55 PM.png

You can create e.g. table to display the data.

All put together6-12-2017 2-48-10 PM.png

BR,

Marcel

Avatar

Level 2

Hello Marcel,

Thanks a lot for your answer. It will be very useful for me.

I've just one problem with it : when I run my workflow, I've a message in my delivery which says :

'Erreur lors de l'évaluation du script 'contenu htmlContent' ligne 4 : instance is not defined'

My delivery is based on a template/model, so maybe it's why it doesn't work properly. I will try with an email delivery without model and see.

Best regards,

Céline

Avatar

Correct answer by
Community Advisor

Hello,

The error is okey

but make sure you are using the right instance variable and actually it is better to use alert activity instead of delivery.

The workflow can look like the one below:

6-12-2017 6-10-23 PM.png

where:

- query population you want report on

- java script activity where you save population from query to the instance variable

  • also you can write this code into the initialization script of the alert activity instead of having JS activity in the workflow6-12-2017 6-21-52 PM.png

- test activity is checking population count > 0 in which case it will send alert message to any operator or group

6-12-2017 6-23-48 PM.png

- alert where you loop over the population and make e.g table from it, which will be send alert to operator

6-12-2017 6-04-32 PM.png

Marcel

Avatar

Level 2

Hello Marcel.

I had a problem with the instance variable, wich appeared to be considered as a String and not as an XML element.

I just add a lign in the script and it's OK :

1229598_pastedImage_0.png

Thank you very much for your help,

Céline

Avatar

Level 5

Hi Marcel marcel.gent.86

Can you just share some screengrabs of the Query configuration?

I assume the data that we want to loop in the delivery template needs to be added in the query, using "Add data" and then referencing the output column alias's in javascript code activity and the for loop in the Alert activity.

Sorry for the spoonfeeding, but a full example which each activity configured and real output field references in the subsequent code would be great.

Thanks

David

Avatar

Community Advisor

Hello David,

you do not have to use "Add data" because the data you are querying are there but under the target element that means you need to query e.g. not @label but [target/@label] or @internalName but [target/@internalName]

1248648_pastedImage_16.png

To get idea what you can bring to the alert pause the alert activity and look at the target in it by right click on the pipeline.

1248613_pastedImage_0.png

But if you add additional data of the same filtering dimension you will not have to use this target prefix

Alert activity could look like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD>

</HEAD>

<BODY>

<P>

<%

var query = xtk.queryDef.create(

<queryDef

schema="temp:queryToPick" operation="select">        

  <select>        

    <node expr="[target/@label]"/>       

    <node expr="[target/@internalName]"/> 

    <node expr="[target/operation/@internalName]"/>

    <node expr="[target/operation/@label]"/>

</select>                            

</queryDef>

);

var items = query.ExecuteQuery();

%>

<P>List of failed workflows in the last 30minutes </P>

<TABLE>

  <THEAD>

  <TR>

    <TD>Workflow</TD>

    <TD>Internal Name</TD></TR></THEAD>

  <TBODY>

<% for each (var item in items){%>

  <TR>

    <TD><%= item.target.@label %> ( <%= item.target.operation.@label %> )</TD>

    <TD><%= item.target.operation.@label %> ( <%= item.target.operation.@internalName %>

    )</TD></TR>

<% } %>

</TBODY>

</TABLE>

</BODY>

</HTML>

Hope this helps.

Marcel

Avatar

Level 10

Thanks Marcel for this very illustrative explanation. It's really great that you have covered everything.

David, simple suggestion use alias in you query additional data to get rid of the target. It will be easy to use that column in your alert activity with alias names.

Regards,

Amit

Avatar

Level 5

marcel.gent.86

Thank you so much for the reply Marcel, this is really great!

Avatar

Level 5

Hi Amit,

Yes, that makes sense - the xpath needed now makes sense to me and adding data/using alias can simplify this.

David

Avatar

Level 5

Hi marcel.gent.86

I've been using this example a lot, it's really great :-)

I have just been trying to implement a solution where I loop in information from the delivery schema (I'm also aggregating recipient delivery log data and adding to the temp schema using enrichment).

I have what I believe should be a working solution (I did a similar much simpler example with recipient data + recipient tracking log data that worked) however, when my workflow gets to the alert activity it errors and gives me the following message in the log:

Failed to load delivery ID 3611 into the cache: This delivery does not exist, has been deleted or the login does not have the required rights.

Firstly, all the deliveries that i want to loop into my alert exist and are visable when viewing "display target" of the temp schema.

Secondly, the delivery ID reference doesn't make sense to me - usually a longer number?

Could you shed any light on what this alert could be or how i could remedy?

Thanks

David

Avatar

Community Advisor

Hello David,

You probably have solved this but I would try to remove proofs from the query --> FCP == "1"  as the logs for these are purged. (I thnk they are deleted after you execute the campaign for real)

Marcel

Avatar

Level 2

Hello,

Apologies to revive a thread that appears to be tied up, but I've followed this example of query > Javascript > Delivery and I get the same error in the Delivery that the instance is not defined. Are you able to assist with this at all?

The code in my JS element is:

var query = xtk.queryDef.create(

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

      <select>

       <node expr="event"/>

       <node expr="count"/>

      </select>

     </queryDef>

  );

  instance.vars.items = query.ExecuteQuery();

  logInfo( instance.vars.items);

The code in my HTML is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD>

</HEAD>

<BODY><%@ include view='MirrorPage' %>

<P><%

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

%> <%= item.event %> <%= item.count %> <%

}

%>

<P></P></BODY></HTML>

Thank you in advance, if possible!

** EDIT **

Just to add, I tried the secondary option. which Marcel explained in great detail, but I then get the error that xtk is not defined.

Avatar

Community Advisor

Hello Andy,

i did not mention this (i did not know this.. see comment from celine) that instance variables can hold strings only. If you have queried target population in JS and saved results in instance vars you need make XML from it again in the delivery.

var items = new XML(instance.vars.items);

PS: also I have found that vars.targetSchema will refer to activity name.. which is very useful when having multiple queries in the pipeline (works only with query and readGroup!)

  • schema={vars.targetSchema}

BR,

Marcel

Avatar

Level 2

Hello Marcel,

Thank you for the further update on this. My code is now essentially identical to the examples provided, yet I'm *still* getting an error of the following:

The code in the JS activity is:

I have now also amended the HTML to add the line you (and Celine) mentioned above:

Am I missing something stupid here?

Thanks in advance!

Andy

Avatar

Community Advisor

Hello Andy,

thats adobe's stuff you can ignore that error or move the js code to the delivery itself. But why you use delivery activity and not alert activity?

Marcel

Avatar

Level 10

Hi Andy,

what you are doing will not work in delivery activity.

Reason: An instance is an object of the workflow, so your instance variable or variable is only available in the workflow execution instance. These variable are not available to MTA(while preparing email delivery personalization) that's why you are getting this error.

Option 1 you can define a new variable at the delivery label and store this variable in the delivery variables.

1411090_pastedImage_0.png

1411109_pastedImage_1.png

1411110_pastedImage_2.png

option 2: use alert activity and you will be able to use your code as is

option 3: add this value as new personalization object in delivery visa delivery advanced properties.

Option 2 will be easy to implement.

Regards,

Amit

Avatar

Level 2

Hi Amit,

Thanks very much for the update on this. Of course!

To address your point, and a very valid one Marcel asked when he also kindly responded, I'm currently working on a very new instance and the Alerts are currently not working. While this is due to be fixed by Adobe within the next couple of weeks, I was looking to implement a work around.

Thanks again, I will see if I can make use of one of the options above. Option 2 (the alerts) was my preference and something I've successfully used in the past so it's a shame it's not currently available to me.

Kind regards,

Andy

Avatar

Level 2

Option 1 did the trick. Thank you very much Amit (and Marcel) for your assistance!