Most tasks in scripted solutions for the Lexmark Document Distributor are completed by creating and manipulating objects. The Solution Builder Toolkit includes three main types of objects specific to development of solutions for Lexmark Document Distributor: top-level objects, prompts, and services.
Top-level objects provide global references to the entity that launched the script, including references to the printer, confirmation page, prompts and services, and task information.
For example, the
object is used to access and set task information, such as the IP of the printer that originated the task or the status displayed with the job in LMC, and the object is used to execute a prompt on the printer.function main() { … // Use taskInfo to get the address of the originating printer var printerIP = taskInfo.printer; // Use taskInfo to set the task status in LMC taskInfo.status = "Running"; … // Use the caller object to execute the prompt caller.ask(mystringprompt); … }
Prompts are used primarily during the document capture stage to receive inputs, including both documents and answers to prompts, from the caller (the printer or software client).
The following example uses a string prompt to illustrate the basic structure necessary to create, manipulate, and execute most prompts, although some prompts use a different structure. For more information and examples for specific prompts, see the Lexmark Document Distributor Script Reference Guide. Note that a separate function is used for the prompt object to enhance readability and reusability of code.
function main() { … var value = promptForString() … } function promptForString() { // Create instance of the StringPrompt object var myprompt = new StringPrompt; // Set text to display when the prompt is executed myprompt.text = "Enter a string"; // Set the default value of the prompt myprompt.value = "sample response"; // Execute the prompt caller.ask(myprompt); // Return the value of the prompt return myprompt.value; }
Notes:
Services are used after document capture for processing and routing documents, as well as providing confirmation of the job to the user. Services may also be used during document capture for processing answers to prompts, such as checking passwords. However, you should avoid excessive processing between successive prompts to prevent unexpected delays for the user.
Use the following structure to create, manipulate, and execute a service:
// Create an instance of the service object "ServiceClass" var myService = new ServiceClass(); // Set properties of the service object myService.field1 = value1; myService.field2 = value2; // Execute the service myService.execute();