Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Package creation from Workflow

Avatar

Level 5

Hi, 

 

Want to know if we can create the packages from the Workflows. I know there is a standard document available :- 

https://helpx.adobe.com/campaign/kb/export-packages-automatically.html

 

But need more inputs on how the code works and how can I use the code. 

 

Thanks,
Adithya

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello,

Here is an example of JS code that generate a package as XML File :

var packageName  = "myPackage";
//export delivery with internalName 'DM123456'
var schema = "nms:delivery";
var conditionExpression = "@internalName = 'DM123456'";
specFileDef = {
  specFile : {
    definition : {
      schema : schema,
      where : {
        condition : [{
            "expr" : conditionExpression
          }]
        }
      }  
    }
  };
var specFile =  NLWS.xtkSpecFile.create( specFileDef );

//Package generation
var package = specFile.GenerateDoc();

//Save content in a file
var packageBuffer = new MemoryBuffer();
packageBuffer.fromString ( package.toXMLString() );
//File name with date included :
packageBuffer.save(  packageName + "_" + formatDate( new Date(), "%4y%2M%2D") + ".xml" );

The package will be the same as if you export with the console.

 

Cedric

View solution in original post

4 Replies

Avatar

Community Advisor

Hi,

 

Use a js activity with the code from that doc page.

Here's a simplified example from a library I wrote once that managed packaging and vcs:

      var selectionExport = xtk.specFile.exportSelection(schema, <where>
        <condition expr={condition}/>
      </where>);
      var f = new File(filepath);
      f.open('w');
      f.writeln('<package buildNumber="' + buildNumber + '" buildVersion="' + buildVersion + '">');
      f.writeln(selectionExport.entities.toXMLString());
      f.writeln('</package>');
      f.close();

The exportSelection() endpoint is in xtk:package.js btw if you want to see how it works.

 

Thanks,

-Jon

Avatar

Level 5
Hi , Thanks for the inputs on this, Sure will try to work on this code and look more in the package.js. Much helpful thank you !!!

Avatar

Correct answer by
Community Advisor

Hello,

Here is an example of JS code that generate a package as XML File :

var packageName  = "myPackage";
//export delivery with internalName 'DM123456'
var schema = "nms:delivery";
var conditionExpression = "@internalName = 'DM123456'";
specFileDef = {
  specFile : {
    definition : {
      schema : schema,
      where : {
        condition : [{
            "expr" : conditionExpression
          }]
        }
      }  
    }
  };
var specFile =  NLWS.xtkSpecFile.create( specFileDef );

//Package generation
var package = specFile.GenerateDoc();

//Save content in a file
var packageBuffer = new MemoryBuffer();
packageBuffer.fromString ( package.toXMLString() );
//File name with date included :
packageBuffer.save(  packageName + "_" + formatDate( new Date(), "%4y%2M%2D") + ".xml" );

The package will be the same as if you export with the console.

 

Cedric

Avatar

Level 5
Hi Rey, Thank you for this example and will check by implementing this. Regards, Adithya