Automating Package Export - Campaign Classic

ankurm40172185

15-05-2018

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_p...

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'?>

Accepted Solutions (1)

Accepted Solutions (1)

MarcelSzimonisz

MVP

16-05-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

1488579_pastedImage_1.png

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

1488580_pastedImage_2.png

     - 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

Answers (6)

Answers (6)

MarcelSzimonisz

MVP

16-05-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.");

1488468_pastedImage_11.png

Marcel

ankurm40172185

16-05-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.

ankurm40172185

16-05-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.