Script Manager

Write, Edit, and Trigger a Script

A script has access to all the QPP Server objects and can invoke all the operations defined in QPP Server API to produce required results. To use a script, you first must save it while logged on to QPP Server.

When you execute a script (manually or scheduled), the script runs the machine on which you have installed Quark Publishing Platform NextGen Server. Script Manager Result window only displays the result of a script or errors returned during a script execution and does not display all the Quark Publishing Platform NextGen Console outputs.

Access QPP Server Objects

You can use the lookup method on the bean RuntimeBeanManager to access Quark Publishing Platform NextGen Server objects. RuntimeBeanManager is a declared bean in Bean Scripting Framework (BSF), which makes it available to scripts by default. For example:

  • var assetFacade = runtimeBeanManager.lookupBean(“restAssetFacade”)

  • var queryFacade = runtimeBeanManager.lookupBean(“queryFacade”)

Load a Script inside another Script

You can load a script inside another scrip through method load(.). For example, if you want to load the script S1, run the command load(S1) inside the current script. You can also load several scripts through the load(.) method; for example, the command load(S1, S2) loads the scripts S1 and S2 in the current script.

The sample script QppFunctions.js in Script Manager contains all the common functions for Quark Publishing Platform NextGen. You can import and load the script instead of loading functions separately to save time.

Log and Debug Scripts

You can use the following methods to log information in scripts:




Prints string values of the variable arguments. The printing occurs on the server standard output. 

For example, you can specify print(“Hello”) or print(arg1, ..., argN).


Logs a debug comment in the QPP Server log file.


Logs an informative comment in the QPP Server log file.


Logs a warning comment in the QPP Server log file.


Logs an error comment in the QPP Server log file.


Logs an exception in the QPP Server log file.

For example:


//do something


catch (err) {



The log level you set for QPP Server determines whether to log comments or not.


Use Utility Methods in Scripts

Use the following methods to read URLs and to run, spawn, and synchronize functions:




Opens a connection to the URL you provide, reads all its data, and then converts the data to a string using specified character encoding or default character coding (if you do not provide an explicit coding argument).

For example, readUrl(url) or readUrl(url, charCoding).


Executes the specified command with the argument you provide as a separate process and returns the exit status of the process.

For example, runCommand(command) or runCommand(command, arg1, ..., argN).


Runs a function or script in a different thread.

For example, function g() {//do something;} or spawn(g);.


Creates a “synchronized” function (a java synchronization method) from an already available function. The new function synchronizes on the “this” object of its invocation.

For example,

var o = {f: sync(function(x) {




Trigger a Script

You can run a Script Manager script in the following ways:

  • Manually run a script from within Service Manager.

  • Schedule a script to run at specific intervals.

  • Specify events that occur within a Quark Publishing Platform NextGen workflow that trigger a script execution.

To trigger a script:

  1. Select a script to see if its content is in the Script Content section of the Script Manager window.

  2. Select File > Save to save the script.

  3. Select the button Trigger at the upper right corner of the Script Content section to open the dialog box Script Execution

  4. In the dialog box Script Execution, make selection(s) based on how you want to run the script: 

    1. To run the script, select Manual.

    2. To schedule a script to run once, select Scheduled Based, select Once, and then select date and time values.

    3. To schedule a script to run at regular intervals, select Scheduled Based, select Recurring, select a frequency, and then set the time for first run.

    4. To trigger a script on the occurrence of a Quark Publishing Platform NextGen event, select Event Based, select an object from the Object Type drop-down menu, select an option from the Change Type drop-down menu.

      The options under Change Type drop-down menu change based on the object type you have selected.
  5. Select OK.

Event-based Script Examples

The following is an example of an event-based script that publishes the PDF version of an asset at a given location when you change the status of an asset. In the example, the object type is ASSET and you change it to type ASSET_CHANGED.





//name of the status, such that when an asset is in given status, it should be published.

var statusName = “Publish”;

// Destination folder for published content

var destinationFolder = “E:/target”;

var assetId = ASSET.get(DefaultMessagePropertyNames.OBJECT_ID);

//Declare QPP Service Facades

var publishFacade = runtimeBeanManager.lookupBean(“publishFacade”);

var assetFacade = runtimeBeanManager.lookupBean(“restAssetFacade”);

/*Map of content types and publishing channel ids. Depending upon the asset’s content type, corresponding publishing channel will be considered.


var publishingChannelsMap = {‘QuarkXPress Project’:’qxpPdf’, ‘Business Document’:’busDocPdf’};


Channel parameters for publishing channel with id : qxpPdf


var parametersForQxpPdf = new java.util.HashMap();

parametersForQxpPdf.put(“SPREAD_VIEW”, “FALSE”);


Channel parameters for publishing channel with id : busDocPdf


var parametersForBusDocPdf = new java.util.HashMap();

parametersForBusDocPdf.put(“XSL_URI”, “classpath:BusDoc2QXPS.xslt”);

parametersForBusDocPdf.put(“QXP_TEMPLATE_URI”, “classpath:BLTEMP.qxp”);


Map of publishing channel id and publishing parameters


var parametersMap = { ‘qxpPdf’ : parametersForQxpPdf, ‘busDocPdf’ : parametersForBusDocPdf};

//Declare a string buffer

var stringBuffer = new StringBuffer();

//names of the attributes to be fetched

var attributes = [“Name”, “Status”, “Content Type”];

var assetInfo = assetFacade.getAsset(assetId, null/*majorVersion*/, null/*minorVersion*/, attributes,

false/*get child asset relations */,

false /* get parent asset relations*/,

[]/*Relation types*/,

null /*Rendition Type */,

null /* Output stream*/,

null /*layout number*/, null/*page number*/);

var attributesList = assetInfo.getAttributeValueList().getAttributeValue();

var assetName = “”;

var currentStatus = “”;

var contentType = “”;

for(var i = 0; i<attributesList.size(); i++){

var attributeValue = attributesList.get(i);


assetName = attributeValue.getValue();



currentStatus = attributeValue.getValue();


if(attributeValue.getName().equalsIgnoreCase(“Content Type”)){

contentType = attributeValue.getValue();



//In case the asset is in desired status



var pdfFile = new File(destinationFolder + “/”+ assetName+”.pdf”);

var fileOutputStream = new FileOutputStream(pdfFile);

//get publishing channel id on the basis of content type

var publishingChannelId = publishingChannelsMap[contentType];

var publishingChannelParameters = parametersMap[publishingChannelId];

publishFacade.publishQPPResource(assetId, fileOutputStream, publishingChannelId, null /* Since we want to publish the given asset, hence delivery channel is null*/,


stringBuffer.append(“\n”+assetName+” has been published as PDF at location “+destinationFolder);


stringBuffer.append(“Error while publishing the asset with name : “+assetName+”\n”);



if(fileOutputStream != undefined){






Manually Run a Script

You can also use the following method to run a script manually:

  1. Select a script to see its content in the Script Content section of the Script Manager window.

  2. In the header toolbar, select QPP > Execute (or select the Execute icon ). 

To run a specific function of a script:

  1. Select QPP > Execute Parameter (or select the Execute Parameter icon ) to open the dialog box Execute Parameters.

  2. In the dialog box Execute Parameters, provide the following details:

    1. Method name

    2. Specify parameter(s) 

  3. Select OK