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
Solved! Go to Solution.
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:
where:
- query population you want report on
- java script activity where you save population from query to the instance variable
- test activity is checking population count > 0 in which case it will send alert message to any operator or group
- alert where you loop over the population and make e.g table from it, which will be send alert to operator
Marcel
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
Views
Replies
Total Likes
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
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
You can create e.g. table to display the data.
All put together
BR,
Marcel
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
Views
Replies
Total Likes
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:
where:
- query population you want report on
- java script activity where you save population from query to the instance variable
- test activity is checking population count > 0 in which case it will send alert message to any operator or group
- alert where you loop over the population and make e.g table from it, which will be send alert to operator
Marcel
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 :
Thank you very much for your help,
Céline
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
Views
Replies
Total Likes
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]
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.
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
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
Views
Replies
Total Likes
Thank you so much for the reply Marcel, this is really great!
Views
Replies
Total Likes
Hi Amit,
Yes, that makes sense - the xpath needed now makes sense to me and adding data/using alias can simplify this.
David
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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!)
BR,
Marcel
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
Views
Replies
Total Likes
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
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.
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
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
Views
Replies
Total Likes
Option 1 did the trick. Thank you very much Amit (and Marcel) for your assistance!
Views
Replies
Total Likes
Views
Likes
Replies