Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Package creation from Workflow

adithyacs86
Level 5
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
CedricRey
Correct answer by
Level 5
Level 5

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

0 Replies
Jonathon_wodnicki
Community Advisor
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

adithyacs86
Level 5
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 !!!
CedricRey
Correct answer by
Level 5
Level 5

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

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