Lexmark X925 Lexmark Document Distributor - Page 20
Adding a library script to a solution, Accessing the functions of a library script
View all Lexmark X925 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 20 highlights
Developing workflow solutions 20 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: • Begin the library section of the script with an empty library() function. • Use the format library.prototype. = function() for function headers. • Create a new library object. This must be done as the last line of the script. 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 will be deployed, then you can write an auto‑configure script that can: • Create a device group. • Add printers to a device group. • Deploy the solution to a device group. • Configure home screens. • Discover devices. • Perform a policy update. • Set the server online.