Automating Package Export - Campaign Classic | Community
Skip to main content
Level 2
May 15, 2018
Solved

Automating Package Export - Campaign Classic

  • May 15, 2018
  • 7 replies
  • 7749 views

Hello All

I am trying to use the below referenced document to generate and download packages but with limited outcome.

https://docs.campaign.adobe.com/doc/AC/en/technicalResources/Technotes/AdobeCampaign_How_to_export_packages_automaticall…

I have created a workflow with the below snippet; the workflow runs without error but i see only a single line as output. More than that; i am unable to find a way to access any generated package files. Would prefer to either find a proper link to ftp them or just download them locally. The end goal is to ftp and upload in another environment.

var query = xtk.queryDef.create(

<queryDef schema="xtk:specFile" operation="select">

<select>

<node expr="@name"/>

<node expr="@namespace"/>

<node expr="data"/>

</select>

<where>  

    <condition expr="[@namespace] = 'XYZ'"  />

   </where>

  

</queryDef>

);

var res = query.ExecuteQuery();

var specFile = xtk.specFile.create(res);

var package = specFile.GenerateDoc();

var fileName = "/tmp/myPackage.xml"

saveXmlFile(package, fileName)

var file = new File("/tmp/myPackage.xml")

file.open()

for each(var line in file)

  logInfo(line)

file.close()

The above highlighted segment gives me just a single line of result:

<?xml version='1.0' encoding='windows-1252'?>

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

Hello ankurm40172185

You have more options here:

1) zip the files and load them to any ftp

     zip them by using execCommand() in JS activity

2) zip files and send them as computed attachment to an email

     - Do not forget to pasword protect them

3) you can zip them and request file transfer job by whoever is managing the remote server

4) you can create web app where you run workflow and trigger download of the zip file

5) request remote access to the server

BR,

Marcel

7 replies

Marcel_Szimonisz
Community Advisor
Community Advisor
May 15, 2018

Hello,

this is not the exact code you are using right?

Do you have data in res?

Marcel

Level 2
May 16, 2018

marcel.gent.86​ This is almost the code i am using; i have package definitions created in a given namespace (used in the where clause). If I do a logInfo on res i can see the package defintion XML being logged in.

Marcel_Szimonisz
Community Advisor
Community Advisor
May 16, 2018

Hello ankurm40172185

i got it

when you xkt.query you will have collection of specFiles <specFile-collection><specFile .../></specFile-collection>

Long story short you need to loop over this collection:

var query = xtk.queryDef.create(

<queryDef schema="xtk:specFile" operation="select">

  <select>

  <node expr="@name"/>

  <node expr="@namespace"/>

  <node expr="data"/>

  </select>

</queryDef>

);

var res = query.ExecuteQuery();

logInfo("Exporting " + Object.keys(res).length + " packages");

var exported = 0;

for (var i = 0;i<Object.keys(res).length; i++){

  try{

  

    var specFile = xtk.specFile.create(res[i]);

    var package = specFile.GenerateDoc();

   

   

    var fileName = "/tmp/package_" + res[i].@name.toLowerCase() + ".xml";

   

    saveXmlFile(package, fileName);

    exported++;

   }catch(err){

         logWarning("Package " + res[i].@name + "has not been exported due to an error.");

   }

}

logInfo("Exported " + exported + " out of " + Object.keys(res).length +" packages requested.");

Marcel

Level 2
May 16, 2018

marcel.gent.86​ Thanks; let me make the query restrictive to a single package and retry. I just want to try this for one record correctly first.

Level 2
May 16, 2018

marcel.gent.86​ Thanks Marcel; you pointed in the right direction; however; as we use managed services I cannot access the files and the adobe documentation doesnt explain how/where to download/ftp this.

Marcel_Szimonisz
Community Advisor
Marcel_SzimoniszCommunity AdvisorAccepted solution
Community Advisor
May 16, 2018

Hello ankurm40172185

You have more options here:

1) zip the files and load them to any ftp

     zip them by using execCommand() in JS activity

2) zip files and send them as computed attachment to an email

     - Do not forget to pasword protect them

3) you can zip them and request file transfer job by whoever is managing the remote server

4) you can create web app where you run workflow and trigger download of the zip file

5) request remote access to the server

BR,

Marcel

Level 2
May 16, 2018

Thanks; let me try this.