Understanding types of scripts

Using profile scripts

Most workflow solution projects include at least one profile script, which, after being assigned to a profile using the Device Policy Editor, can be executed from a printer or software client. A profile script may have any file name other than the names reserved for auto-configure scripts, and each profile script file should contain a main() function.

All LDD objects are available for use in profile scripts, and profile scripts can access library scripts.

The script file TestMFP.js in the TestMFP example template is an example of a profile script.

Using library scripts

Library scripts, which can be accessed only by other scripts, can be used to contain common functionality, such as functions for database access, logging, and progress monitoring. Each function in a library script should use objects and methods appropriate only for scripts that will call it. For example, a library script called by a scheduled script should not use prompt objects or any scan methods.

The script file library.js in the TestSNS example template is an example of a library script.

Adding a library script to a solution

A library script does not require a specific file name. To begin adding a library script, add a blank script in the scripts\ folder.

To define the script as a library script, a specific structure is used:

The following example shows the basic structure of a library script:

function library()
{
}
…
library.prototype.myFunction = function(myArgument1,myArgument2)
{
  …
}
…
new library();

Accessing the functions of a library script

To access the functions of a library script from another script, create an object reference to the library script using the context.callTask() method. The functions in the library script are then available as members of the new object.

The first argument in the callTask() method is always taskInfo.solutionName. The second argument is the script file name with no extension. For example, if the previous library script is named “mylibrary.js,” the following line creates an object reference to that library:

var myLib = context.callTask(taskInfo.solutionName, "mylibrary");

The included functions can then be accessed as follows:

myLib.myFunction(arg1,arg2)

Using auto-configure scripts

If you have detailed knowledge of the LDD system where a solution is deployed, then you can write an auto-configure script that can:

Several events can trigger auto-configure scripts. The following script names determine the events that trigger the scripts:

To add an auto-configure script to a workflow solution, create a script using the selected name in the scripts\ folder of the workflow solution project.

Note: If a solution performs several actions using an auto-configure script, then increase the timeout setting for exporting a solution for deployment. You can configure this setting in the Lexmark preferences.

Using auto-configure methods

All methods used for auto-configure are members of the caller object, which is detailed in the Lexmark Document Distributor Script Reference. These methods can also be used in a scheduled script in which the caller object is assigned as follows:

var caller = context.getObject("autoconfigUtilities")

For an example of an auto-configure script that uses several of the available methods, see the configureNewSolution.js file in the TestMFP template in the Eclipse software. Also, the simplelog.js file in the scheduled\ folder of the TestMFP template contains the preceding var statement and uses auto-configure methods.

Configuring the home screen with auto-configure

The method caller.setWelcomeScreen(groupName, solutionName, fileName) configures the home screen for the specified solution in the specified group. The specified XML file, located in the “src\solution\welcomescreen\” folder, provides a description of the layout of the home screen.

The description of a home screen for an individual device class is specified using the element <welcomescreen model="class">, where class is one of the following:

The layout is specified as an integer in the contents of the <buttonLayout> element. The settings apply as shown in the following table.

Buttons for the home screen are contained within a <buttons> element. Each button is defined using the <button> element, which contains the following child elements to define the properties of a button:

Device class

Valid contents of the <buttonLayout> element

Valid contents of the <action> element

etask

19

The value specifies the number of buttons.

Standard printer functions
  • Copy

  • Fax

  • Email

  • Forms

  • Printer Panel

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

sfp_etask

1n

The value specifies the number of buttons and must be the same as the number of <button> elements defined.

LDD profile
  • Single Profile

etask2

19

The value specifies the number of buttons on the first page of the home screen. Three subsequent 9-button pages are included in the layout, providing 27 more buttons.

Standard printer functions
  • Copy

  • Fax

  • Email

  • Ftp

  • Held Jobs

  • Search Held Jobs

  • Held Faxes

  • Lock Device

LDD profile
  • Single Profile

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • Placeholder

etask2+

19

The value specifies the number of buttons on the first page of the home screen. Three subsequent 9-button pages are included in the layout, providing 27 more buttons.

Standard printer functions
  • Change Language

  • Copy

  • Copy Shortcuts

  • Fax

  • Fax Shortcuts

  • Email

  • Email Shortcuts

  • Ftp

  • Ftp Shortcuts

  • Held Jobs

  • Search Held Jobs

  • Held Faxes

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

  • Placeholder

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

  • Ftp + Profile

sfp_etask2+

19

The value specifies the number of buttons on the first page of the home screen. Three subsequent 9-button pages are included in the layout, providing 27 more buttons.

Standard printer functions
  • Change Language

  • Search Held Jobs

  • Held Jobs

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

  • Placeholder

etask3

110

The value specifies the number of buttons on the first page of the home screen. Three subsequent 10-button pages are included in the layout, providing 30 more buttons.

Standard printer functions
  • Change Language

  • Copy

  • Copy Shortcuts

  • Fax

  • Fax Shortcuts

  • Email

  • Email Shortcuts

  • Ftp

  • Ftp Shortcuts

  • Held Jobs

  • Search Held Jobs

  • Held Faxes

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

  • Ftp + Profile

sfp_etask3

14

The value specifies the number of buttons on the first page of the home screen. Three subsequent 4-button pages are included in the layout, providing 12 more buttons.

Standard printer functions
  • Change Language

  • Search Held Jobs

  • Held Jobs

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

etask4

110

The value specifies the number of buttons on the first page of the home screen. Three subsequent 10-button pages are included in the layout, providing 30 more buttons.

Standard printer functions
  • Change Language

  • Copy

  • Copy Shortcuts

  • Fax

  • Fax Shortcuts

  • Email

  • Email Shortcuts

  • Ftp

  • Ftp Shortcuts

  • Search Held Jobs

  • Held Jobs

  • Release Held Faxes

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

  • cSF Apps

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

  • Ftp + Profile

etask4(4.3)

14

The value specifies the number of buttons on the first page of the home screen. Three subsequent 4-button pages are included in the layout, providing 12 more buttons.

Standard printer functions
  • Change Language

  • Copy

  • Copy Shortcuts

  • Fax

  • Fax Shortcuts

  • Email

  • Email Shortcuts

  • Ftp

  • Ftp Shortcuts

  • Search Held Jobs

  • Held Jobs

  • Release Held Faxes

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

  • cSF Apps

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

  • Ftp + Profile

sfp_etask4

14

The value specifies the number of buttons on the first page of the home screen. Three subsequent 4-button pages are included in the layout, providing 12 more buttons.

Standard printer functions
  • Change Language

  • Search Held Jobs

  • Held Jobs

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Placeholder for an eSF application installed with the solution
  • App Reservation

sfp_etask4(7)

110

The value specifies the number of buttons on the first page of the home screen. Three subsequent 10-button pages are included in the layout, providing 30 more buttons.

Standard printer functions
  • Change Language

  • Search Held Jobs

  • Held Jobs

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Placeholder for an eSF application installed with the solution
  • App Reservation

etask5

115

The value specifies the number of buttons on the first page of the home screen. Four subsequent 15-button pages are included in the layout, providing 60 more buttons.

Standard printer functions
  • Copy

  • Email

  • Fax

  • Held Faxes

  • Release Held Faxes

  • Status/Supplies

  • Job Queue

  • Change Language

  • Settings

  • Shortcuts

  • USB Drive

  • Held Jobs

  • Bookmarks

  • FTP

  • Scan Profiles

  • Lock Device

LDD profile
  • App Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

  • Placeholder

Standard functions overridden by profiles
  • Copy + Profile

  • Fax + Profile

  • Email + Profile

  • Ftp + Profile

sfp_etask5

18

The value specifies the number of buttons on the first page of the home screen. Eight subsequent 8-button pages are included in the layout, providing 64 more buttons.

Standard printer functions
  • Status/Supplies

  • Job Queue

  • Change Language

  • Settings

  • USB Drive

  • Held Jobs

  • Bookmarks

  • Lock Device

LDD profile
  • App Profiles

Placeholder for an eSF application installed with the solution
  • App Reservation

  • Placeholder

x642

14

If the value is 13, then it specifies the number of buttons. If the value is 4, then it specifies a four-page layout of 4 buttons each, providing 16 total buttons.

Standard printer functions
  • Copy

  • Fax

  • Email

  • Ftp

  • Held Jobs

LDD profile
  • Single Profile

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • Placeholder

t656

19

The value specifies the number of buttons on the first page of the home screen. Three subsequent 9-button pages are included in the layout, providing 27 more buttons.

Standard printer functions
  • Change Language

  • Held Jobs

  • Search Held Jobs

  • Usb Drive

  • Bookmarks

  • Jobs by user

  • Lock Device

LDD profile
  • Single Profile

List of profiles
  • Profiles

Shortcut
  • Shortcut

Placeholder for an eSF application installed with the solution
  • App Reservation

  • Placeholder


Determine the placement of each button by the order in which the buttons are defined.

The following sample XML file specifies a home screen for e-Task 2 devices:

<?xml version="1.0" encoding="UTF-8"?>
<welcomescreen model="etask2">
   <buttonLayout>5</buttonLayout>
   <buttons>
      <!-- Buttons in page 1 -->
      <!-- A layout of 5 buttons is used, but only positions
           2 and 3 on the first page contain buttons -->
      <button/>
      <button>
         <action>Copy</action>
      </button>
      <button/>
      <button>
         <action>Fax</action>
         <displayText>My Fax</displayText>
      </button>
      <button/>
         
      <!-- Buttons in page 2 (page 2 starts after specifying all
           5 buttons on the first page) -->
      <!-- Place a profile button in position 5, using empty
           buttons for the first 4 -->
      <button/>
      <button/>
      <button/>
      <button/>
      <button>
         <action>Single Profile</action>
         <profileName>TestMFP</profileName>
         <displayText>Test MFP</displayText>
         <displayIcon>images\\testmfp_up.gif</displayIcon>
      </button>
   </buttons>
 </welcomescreen>

An example file for the home screen on each device class can be found in the “\src\solution\welcomescreen” folder of the TestMFP example template.

Using forms merge scripts

You can use forms merge scripts to perform advanced management of forms merge operations or modify forms merge data and output documents. Using a forms merge script, you can:

The following scripting elements are unique to forms merge scripts:

The script file TestMergeScript.js in the TestMergeScript example template is an example of a forms merge script.

Scripting for different stages of a forms merge

Forms merge scripts use callbacks to define functions that are activated at various stages of a forms merge job. The main() function in the script contains any actions executed when the job is first submitted, as well as assignments of callback functions. You only need to define and assign callback functions for the stages where scripted actions are necessary.

Assign callback functions to the following fields of the mergeContext top-level object at the end of the main() function (or, when using exception handling, at the end of the try block within the function):

mergeContext field to which the callback function is assigned

Stage of forms merge at which the assigned function is called

Parameters of assigned callback function

mergeContext.renderDataPage

After each page of input data is read

page—DataPage object containing the data from the page

mergeContext.endDoc

After input from a single form is completed and the resulting PDF is rendered

fileName—String containing the path and file name of the output PDF

mergeContext.endDataSet

After input from a single form is completed and the resulting dataset is generated

Note: A dataset is generated only if this callback function is defined.

fileName—String containing the path and file name of the dataset, which can be sent to a printer with a forms card

mergeContext.endData

After all input data is read

None

mergeContext.endJob

After all PDFs included in the job have been rendered

files—Array of strings containing the file names of all output PDFs


A forms merge script with all callback functions defined is structured as follows:

function main()
{
   try
   {
      //Actions to take when job is first submitted
      …
      //Assignment of callback functions
      mergeContext.renderDataPage = myRenderDataPageFunction;
      mergeContext.endDoc = myEndDocFunction;
      mergeContext.endDataSet = myEndDataSetFunction;
      mergeContext.endData = myEndDataFunction;
      mergeContext.endJob = myEndJobFunction;
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

function myRenderDataPageFunction(page)
{
   try
   {
      //Actions to take after each page of data
      //is read from the input data
      …
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

function myEndDocFunction(fileName)
{
   try
   {
      //Actions to take after input from a single form is completed
      //and the resulting PDF is rendered
      …
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

function myEndDataSetFunction(fileName)
{
   try
   {
      //Actions to take after input from a single form is completed
      //and the resulting dataset is generated
      …
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

function myEndDataFunction()
{
   try
   {
      //Actions to take after all input data is read
      …
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

function myEndJobFunction(files)
{
   try
   {
      //Actions to take after all PDFs included
      //in the job have been rendered
      …
   }
   catch(e)
   {
      //Logging and other exception handling
      …
      throw e;
   }
}

Using the PrintClass service with forms merge scripts

As in all scripts, you can use the PrintClass service to send a document to a printer.

Two fields are particularly important when using PrintClass in a forms merge script:

Printing forms on printers with forms cards

If you have printers with forms cards, you can choose to print forms using a dataset, an XML list of key-value pairs that represent input data. Most of the information about the final output form is stored on the forms card, and only the dataset is sent to the printer. Because less data is transferred over the network, use of datasets may provide better performance with limited network bandwidth.

To use a dataset, define mergeContext.endDataSet in main(), and then use the function assigned to the field to send the dataset to the printer.

Using scheduled scripts

Scheduled scripts can be created to assist with system maintenance. Since scheduled scripts are launched by the LDD system itself rather than a printer or software client, they cannot use objects that require user intervention, such as prompt objects and scan methods.

You can use auto-configure methods for making changes to the LDD system in scheduled scripts if the caller object is assigned as follows:

var caller = context.getObject("autoconfigUtilities")

You can also access an Additional Options field that an administrator can populate with free-form text when scheduling the task in LMC. You should provide the LDD administrator with documentation on any values that the script expects in the field. Scripts access the value supplied by the administrator using the field taskInfo.additionalOptions.

To create a scheduled script, create a new script in the src\scripts\scheduled\ folder.

For more information about adding scheduled scripts in LMC, see the Lexmark Document Distributor Administrator's Guide.

Examples of scheduled scripts can be found in the TestMFP and TestSNS example templates.