Highlighted

Render Delivery Ad Hoc with only content/content set

eliasa31934321

21-02-2017

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

Replies

Highlighted

florentlb

21-02-2017

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. 

Highlighted

eliasa31934321

22-02-2017

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.

Highlighted

Vapsy

Employee

23-02-2017

Hi Elias,

If I've understood your requirement correctly, the following steps should help you dynamically set the content of outgoing email.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. 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

Highlighted

eliasa31934321

27-02-2017

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.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated. 
  1. 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

Highlighted

Amit_Kumar

MVP

28-03-2017

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.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated. 
  1. 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

Highlighted

eliasa31934321

29-03-2017

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.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated. 
  1. 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>
);

Highlighted

Amit_Kumar

MVP

02-04-2017

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.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated. 
  1. 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

Highlighted

eliasa31934321

05-04-2017

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.

  1. I've created a delivery template with content as "Old HTML source".
  2. Used a delivery activity to create deliveries automatically from the template created in Step1.
  3. On the script tab, using JavaScript, I'm dynamically modifying the HTML source of the delivery being generated. 
  1. 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.

  1.  
  2. /**
  3. * Create a delivery from a template and set the html content given as parameter
  4. * @param {String} templateName The intenral name of the template to create the delivery from
  5. * @param {String} htmlContent The full HTML content of the delivery
  6. * @param {String} textContent The full text content of the delivery
  7. * @param {String} subject The subject of the delivery
  8. * @return {String} The internal name if the newly created delivery, or null if something went wrong
  9. */
  10. function newCreateDelivery(templateName, htmlContent,textContent,subject) {
  11. var qry = xtk.queryDef.create(<queryDef schema="nms:delivery" operation="getIfExists">
  12. <where>
  13. <condition expr={ "@isModel = 1 and @internalName = '" + templateName+"'" }/>
  14. </where>
  15. </queryDef>);
  16. qry.SelectAll(true);
  17. var result = qry.GetInstanceFromModel("nms:delivery");
  18.  
  19. if(result.length() > 0) {
  20. result.content.html.source = htmlContent;
  21. result.content.text.source = textContent;
  22. result.mailParameters.subject = subject;
  23.  
  24. xtk.session.Write(result);
  25.  
  26. return result.@internalName;
  27. }
  28. else
  29. return null;
  30. }

 

Then to send the email use following:

 
  1. var emailTemplateInternalName = newCreateDelivery(deliveryTemplateName, htmlContent,textContent,subject);
  2.  
  3. nms.delivery.QueueNotification("emailTemplateInternalName",
  4. <delivery>
  5. <targets>
  6. <deliveryTarget>
  7. <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
  8. <where>
  9. <condition expr={'@id ='+ "put yours recipientId here or change condition to included in for comma seprated values or any logic"}/>
  10. </where>
  11. </targetPart>
  12. </deliveryTarget>
  13. </targets>
  14. </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