How to get Delivery Content in JS using queryDef? | Community
Skip to main content
Level 6
May 16, 2019

How to get Delivery Content in JS using queryDef?

  • May 16, 2019
  • 2 replies
  • 11111 views

Hello Folks,

I have content from AEM which gets synced in Campaign Email Delivery. I want to retrieve the updated content every time when it gets refreshed. I retrieved using "var deliveryContent = delivery.content.html.source;"  in the Delivery Script using variables.

But it is not giving updated content, since AEM Content gets refreshed automatically during Delivery Run-time Analysis. I am getting same old content every time. So would like to understand is there any way where we can use queryDef on [content/html/source] in JS afor the Delivery ID passed and retrieve content after it is synced from AEM

Could someone please throw some light on this, quick help is appreciated

Regards,

Sri Bhargav

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Level 6
May 16, 2019

Hello Folks,

I tried something like below:

var query = xtk.queryDef.create(

  <queryDef schema="nms:delivery" operation="select">

    <select>

      <node expr="[content/html/source]"/>

      <node expr="@label"/>

    </select>

    <where>

      <condition expr={"@internalName = '"+deliveryInternalName+"'"}/>

    </where>

  </queryDef>),result;

  result = query.ExecuteQuery();

  var statsResults = result.delivery;

for(var eachResp in statsResults)

{

  var deliveryLabel = statsResults[eachResp].@label;

  logInfo(deliveryLabel);

 

  //var deliveryContent = statsResults[eachResp].[content/html/source];

 

  var dataStr = sqlGetMemo("SELECT mData from nmsDelivery WHERE sInternalName="+eachResp.@internalName);

  //var dataXml = DOMDocument.fromXMLString(dataStr);

  //var content = dataXml.root.getValue("content/html/source");

}

But Unable to fetch content and getting various errors, since it is an XML Field stored under path: content/html/source, is there any specific way to access this? If so let me know!

Regards,

Sri Bhargav

Level 6
May 16, 2019

Vipul Raghav

@Jean-Serge Biron

Adhiyan

wodnicki

Can you help?

Regards,

Sri Bhargav

Jonathon_wodnicki
Community Advisor
Community Advisor
May 16, 2019

Hi,

To fetch AEM content for a delivery, use nms.delivery.aemGetContent(delivery).

To select paths in queryDef, use alias="html" in the <node/> element.

Thanks,

-Jon

Level 6
May 16, 2019

Hi Jon,

Apologies! I didn't understand completely what you mentioned. Quite confusing

Where do i need to use nms.delivery.aemGetContent(delivery), is it in Select Query? If possible can you provide me any snippet as reference please

Regards,

Sri Bhargav

Level 6
May 20, 2019

Hello,

Could someone please help me in looking into error?

Regards,

Sri Bhargav


Hello Jon,

I understood from the above method that nms.delivery.aemGetContent(delivery) is a JS functiion and there it does some logic for pulling content. But while checking so why am i getting "No Permalink provided to identify the content".

Any Inputs please?

Regards,

Sri Bhargav