Hello Campaigners!
Background: I have created a flow for deliveries to be created automatically and have set the Delivery with tracking, validation, mailParameters and Content. I cannot set the last piece that seems required, HTML content under delivery/content/html/source. This because it is rendered from a JavaScript Template.
Question: I want to render deliveries programmatically but as I trigger my workflow to send out the delivery the old HTML is still in the email if I don't open up the delivery templates first. Is there a specific method that I can use to trigger the rendering of the HTML content under delivery/content/html/source? I have tried a few of the methods in publishing and delivery.
ANY help is MUCH appreciated - thanks a ton in advance!
Regards
Elias
Views
Replies
Total Likes
Hello Elias,
In this example a script is used to force the loading of an FTP content in a workflow delivery. Perhaps this could be applied somehow to your use case?
Hope this helps,
Florent.
Views
Replies
Total Likes
florentlb wrote...
Hello Elias,
In this example a script is used to force the loading of an FTP content in a workflow delivery. Perhaps this could be applied somehow to your use case?
Hope this helps,
Florent.
Hi Florent!
Thanks for your reply. Unfortunately this is something I have already tried and that does not work in my use case.
The location,delivery/content/html/source, where it adds the file is correct, but I have to somehow refresh the generation of my JavaScript template or set the source by first extracting the Javascript template based on my content under content/content. If you have done something similar to this please let me know :).
Thanks again for the reply.
Views
Replies
Total Likes
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Views
Replies
Total Likes
Vipul Raghav wrote...
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
I've created a delivery template with content as "Old HTML source".
Used a delivery activity to create deliveries automatically from the template created in Step1.
On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Hello Vipul,
What I want to achieve is a refresh of the content - or if I am to set it manually, like in your case, I need to first generate the content from content.content and/or the PM/DS/Form/delivery files. I have everything but delivery.content.html.source set and I just want to generate the file to put in delivery.content.html.source. Does this make sense or can I help out with clarifying this even more :)?
Thanks in advance!
Regards
Elias
Views
Replies
Total Likes
Hi Elias,
Sorry but I'm not able to understand your requirement completely.
Regards,
Vipul
Views
Replies
Total Likes
eliasa31934321 wrote...
Vipul Raghav wrote...
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
I've created a delivery template with content as "Old HTML source".
Used a delivery activity to create deliveries automatically from the template created in Step1.
On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Hello Vipul,
What I want to achieve is a refresh of the content - or if I am to set it manually, like in your case, I need to first generate the content from content.content and/or the PM/DS/Form/delivery files. I have everything but delivery.content.html.source set and I just want to generate the file to put in delivery.content.html.source. Does this make sense or can I help out with clarifying this even more :)?
Thanks in advance!
Regards
Elias
Hi Elias,
what do you want in your content? is this a personalized information? do you mind sharing the old content and expected content here? are you loading content from FTP location or you are generating that logically using JS?
Regards,
Amit
Views
Replies
Total Likes
Amit_Kumar wrote...
eliasa31934321 wrote...
Vipul Raghav wrote...
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
I've created a delivery template with content as "Old HTML source".
Used a delivery activity to create deliveries automatically from the template created in Step1.
On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Hello Vipul,
What I want to achieve is a refresh of the content - or if I am to set it manually, like in your case, I need to first generate the content from content.content and/or the PM/DS/Form/delivery files. I have everything but delivery.content.html.source set and I just want to generate the file to put in delivery.content.html.source. Does this make sense or can I help out with clarifying this even more :)?
Thanks in advance!
Regards
Elias
Hi Elias,
what do you want in your content? is this a personalized information? do you mind sharing the old content and expected content here? are you loading content from FTP location or you are generating that logically using JS?
Regards,
Amit
Hi Amit,
I want to set the content with a feed from a web requeest. It is in some ways personalized. Content could be "a", "b" and "c" the first time I generate it and "b" "d" and "g" the second time - and I need the structure from the publication model(JS/Form/Data Schema) in order to make it render correctly. I generate the content using JavaScript, where I also make the request. Here is and example of what I get back from the JavaScript file, which I then save in the delivery:
<Template _operation="insert" xtkschema="domain:Template" template="22" status="0">
<box id="1" blockType="12" area={area} separator="true" banner={areas[area-1].banner} xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:domain:Template" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.ord/2001/XMLSchema-instance">
<box1 imageUrl={areas[area-1].imageUrl} id={counter} headerText={title} linkHeader="false" useButton="false">
<contentText>{description}</contentText>
</box1>
</box>
</Template>
This content would the be written to the delivery, something like this:
var boxBlockCollection = new XML(js_file_method(param1,param2).replace(/^[\n\s]*<\?[\sA-Z=\-0-9\"\'\.]*\?>/i, ""));
xtk.session.Write(
<delivery _operation="insertOrUpdate" _key="@id" id={areas[j].areaId} xtkschema="nms:delivery" deliveryState="0" publishing-name="Template" publishing-namespace="domain" publishing="Template">
<tracking enabled="true"/>
<validation useContentValidation="false"/>
<mailParameters>
<subject>
Example text: {areas[j].areaName}
</subject>
</mailParameters>
<content>
<content>
{boxBlockCollection}
</content>
</content>
</delivery>
);
Views
Replies
Total Likes
eliasa31934321 wrote...
Amit_Kumar wrote...
eliasa31934321 wrote...
Vipul Raghav wrote...
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
I've created a delivery template with content as "Old HTML source".
Used a delivery activity to create deliveries automatically from the template created in Step1.
On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Hello Vipul,
What I want to achieve is a refresh of the content - or if I am to set it manually, like in your case, I need to first generate the content from content.content and/or the PM/DS/Form/delivery files. I have everything but delivery.content.html.source set and I just want to generate the file to put in delivery.content.html.source. Does this make sense or can I help out with clarifying this even more :)?
Thanks in advance!
Regards
Elias
Hi Elias,
what do you want in your content? is this a personalized information? do you mind sharing the old content and expected content here? are you loading content from FTP location or you are generating that logically using JS?
Regards,
Amit
Hi Amit,
I want to set the content with a feed from a web requeest. It is in some ways personalized. Content could be "a", "b" and "c" the first time I generate it and "b" "d" and "g" the second time - and I need the structure from the publication model(JS/Form/Data Schema) in order to make it render correctly. I generate the content using JavaScript, where I also make the request. Here is and example of what I get back from the JavaScript file, which I then save in the delivery:
<Template _operation="insert" xtkschema="domain:Template" template="22" status="0">
<box id="1" blockType="12" area={area} separator="true" banner={areas[area-1].banner} xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:domain:Template" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.ord/2001/XMLSchema-instance">
<box1 imageUrl={areas[area-1].imageUrl} id={counter} headerText={title} linkHeader="false" useButton="false">
<contentText>{description}</contentText>
</box1>
</box>
</Template>
This content would the be written to the delivery, something like this:
var boxBlockCollection = new XML(js_file_method(param1,param2).replace(/^[\n\s]*<\?[\sA-Z=\-0-9\"\'\.]*\?>/i, ""));
xtk.session.Write(
<delivery _operation="insertOrUpdate" _key="@id" id={areas[j].areaId} xtkschema="nms:delivery" deliveryState="0" publishing-name="Template" publishing-namespace="domain" publishing="Template">
<tracking enabled="true"/>
<validation useContentValidation="false"/>
<mailParameters>
<subject>
Example text: {areas[j].areaName}
</subject>
</mailParameters>
<content>
<content>
{boxBlockCollection}
</content>
</content>
</delivery>
);
Hi Elias,
If i understood your problem statement correctly then you need to create email deliveries with dynamic content every time you trigger a workflow from a given email template.you have to do something like this.
/** * Create a delivery from a template and set the html content given as parameter * @param {String} templateName The intenral name of the template to create the delivery from * @param {String} htmlContent The full HTML content of the delivery * @param {String} textContent The full text content of the delivery * @param {String} subject The subject of the delivery * @return {String} The internal name if the newly created delivery, or null if something went wrong */ function newCreateDelivery(templateName, htmlContent,textContent,subject) { var qry = xtk.queryDef.create(<queryDef schema="nms:delivery" operation="getIfExists"> <where> <condition expr={ "@isModel = 1 and @internalName = '" + templateName+"'" }/> </where> </queryDef>); qry.SelectAll(true); var result = qry.GetInstanceFromModel("nms:delivery"); if(result.length() > 0) { result.content.html.source = htmlContent; result.content.text.source = textContent; result.mailParameters.subject = subject; xtk.session.Write(result); return result.@internalName; } else return null; }
Then to send the email use following:
var emailTemplateInternalName = newCreateDelivery(deliveryTemplateName, htmlContent,textContent,subject); nms.delivery.QueueNotification("emailTemplateInternalName", <delivery> <targets> <deliveryTarget> <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'> <where> <condition expr={'@id ='+ "put yours recipientId here or change condition to included in for comma seprated values or any logic"}/> </where> </targetPart> </deliveryTarget> </targets> </delivery>);
Hope this helps,
Amit
Views
Replies
Total Likes
Amit_Kumar wrote...
eliasa31934321 wrote...
Amit_Kumar wrote...
eliasa31934321 wrote...
Vipul Raghav wrote...
Hi Elias,
If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.
I've created a delivery template with content as "Old HTML source".
Used a delivery activity to create deliveries automatically from the template created in Step1.
On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated.
delivery.content.html.source = "<h1>New HTML</h1>";
Hope this helps.
Regards,
Vipul
Hello Vipul,
What I want to achieve is a refresh of the content - or if I am to set it manually, like in your case, I need to first generate the content from content.content and/or the PM/DS/Form/delivery files. I have everything but delivery.content.html.source set and I just want to generate the file to put in delivery.content.html.source. Does this make sense or can I help out with clarifying this even more :)?
Thanks in advance!
Regards
Elias
Hi Elias,
what do you want in your content? is this a personalized information? do you mind sharing the old content and expected content here? are you loading content from FTP location or you are generating that logically using JS?
Regards,
Amit
Hi Amit,
I want to set the content with a feed from a web requeest. It is in some ways personalized. Content could be "a", "b" and "c" the first time I generate it and "b" "d" and "g" the second time - and I need the structure from the publication model(JS/Form/Data Schema) in order to make it render correctly. I generate the content using JavaScript, where I also make the request. Here is and example of what I get back from the JavaScript file, which I then save in the delivery:
<Template _operation="insert" xtkschema="domain:Template" template="22" status="0">
<box id="1" blockType="12" area={area} separator="true" banner={areas[area-1].banner} xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:domain:Template" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.ord/2001/XMLSchema-instance">
<box1 imageUrl={areas[area-1].imageUrl} id={counter} headerText={title} linkHeader="false" useButton="false">
<contentText>{description}</contentText>
</box1>
</box>
</Template>
This content would the be written to the delivery, something like this:
var boxBlockCollection = new XML(js_file_method(param1,param2).replace(/^[\n\s]*<\?[\sA-Z=\-0-9\"\'\.]*\?>/i, ""));
xtk.session.Write(
<delivery _operation="insertOrUpdate" _key="@id" id={areas[j].areaId} xtkschema="nms:delivery" deliveryState="0" publishing-name="Template" publishing-namespace="domain" publishing="Template">
<tracking enabled="true"/>
<validation useContentValidation="false"/>
<mailParameters>
<subject>
Example text: {areas[j].areaName}
</subject>
</mailParameters>
<content>
<content>
{boxBlockCollection}
</content>
</content>
</delivery>
);
Hi Elias,
If i understood your problem statement correctly then you need to create email deliveries with dynamic content every time you trigger a workflow from a given email template.you have to do something like this.
/**
* Create a delivery from a template and set the html content given as parameter
* @param {String} templateName The intenral name of the template to create the delivery from
* @param {String} htmlContent The full HTML content of the delivery
* @param {String} textContent The full text content of the delivery
* @param {String} subject The subject of the delivery
* @return {String} The internal name if the newly created delivery, or null if something went wrong
*/
function newCreateDelivery(templateName, htmlContent,textContent,subject) {
var qry = xtk.queryDef.create(<queryDef schema="nms:delivery" operation="getIfExists">
<where>
<condition expr={ "@isModel = 1 and @internalName = '" + templateName+"'" }/>
</where>
</queryDef>);
qry.SelectAll(true);
var result = qry.GetInstanceFromModel("nms:delivery");
if(result.length() > 0) {
result.content.html.source = htmlContent;
result.content.text.source = textContent;
result.mailParameters.subject = subject;
xtk.session.Write(result);
return result.@internalName;
}
else
return null;
}
Then to send the email use following:
var emailTemplateInternalName = newCreateDelivery(deliveryTemplateName, htmlContent,textContent,subject);
nms.delivery.QueueNotification("emailTemplateInternalName",
<delivery>
<targets>
<deliveryTarget>
<targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={'@id ='+ "put yours recipientId here or change condition to included in for comma seprated values or any logic"}/>
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>);
Hope this helps,
Amit
Hi Amit,
thank you for the response! This is not exactly what I'm looking for - I wish for the result.content.html.source to be updated with what I saved as XML content in the delivery template. I want the data in content.content to be generated into HTML and put in content.html.source.
Is this something you know how to do?
In other words I want this to be generated into HTML and saved in result.content.html.source:
<Template _operation="insert" xtkschema="domain:Template" template="22" status="0">
<box id="1" blockType="12" area={area} separator="true" banner={areas[area-1].banner} xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:domain:Template" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.ord/2001/XMLSchema-instance">
<box1 imageUrl={areas[area-1].imageUrl} id={counter} headerText={title} linkHeader="false" useButton="false">
<contentText>{description}</contentText>
</box1>
</box>
</Template>
Regards,
Elias
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies