The Watch Object

OL Connect Workflow scripting offers a number of methods of communicating with your process by means of OL Connect Workflow automation object's methods and functions. The automation object is available in all 4 languages through their own syntax - the examples provided here are for JavaScript.

Note: While the functions here are in mixed case to simplify reading, it's important to note that some languages (especially JavaScript) are case-sensitive and will require the proper case. Examples in this chapter will always use the proper case when relevant.

Here is a list of the methods and functions that are available to you through the automation object (or "Watch" object). While these examples are all in JavaScript, you can click on any variable name to open a page to see examples for each supported language.

Variable Name Description
Example Usage and VBScript
Script.ReturnValue Returns a boolean True or False value to a Workflow scripted condition.
Copy
Script.ReturnValue = 1;
Watch.ExecuteExternalProgram Calls and executes an external program in the command line.
Copy
Watch.ExecuteExternalProgram("lpr -S 192.168.100.001 -P auto c:\\myfile.ps", "c:\\", 0, true);

Watch.ExpandResourcePath

 

Expands a Connect resource file name (e.g. invoice.OL-template) to its fully qualified path (e.g. C:\ProgramData\Objectif Lune\PlanetPress Workflow\Documents\invoice.OL-template).

Copy
var fullPath = Watch.ExpandResourcePath("invoice.OL-template");
Watch.ExpandString Retrieves the content of any Workflow string, containing any variable available to Watch, including data selections.
Copy
var watchDate = Watch.ExpandString("%y-%m-%d");

Watch.GetConnectToken

 

Uses the default Connect Server host as defined in the Workflow preferences to log into the Connect Server and retrieve an authorization token.

Copy
var tokenConnect = Watch.GetConnectToken();

Watch.GetConnectTokenEx2

 

Uses the arguments passed to it to log into the Connect Server and retrieve an authorization token.

Copy
var tokenConnect = Watch.GetConnectTokenEx("localhost", 1234, "myUser", "secret", 0);
Watch.GetJobFileName Retrieves a string containing the job path and file name located in the job spool folder.
Copy
var s = Watch.GetJobFilename();
Watch.GetJobInfo Retrieves the content of a numbered job info (%1 to %9).
Copy
var s = Watch.GetJobInfo(9);
Watch.GetMetadataFilename Retrieves a string containing the job's metadata path and filename. This is useful when using the Metadata API in your script. (See Metadata API)
Copy
var s = Watch.GetMetadataFileName();
Watch.GetOriginalFileName Retrieves a string containing the job's original path and filename. Note: this filename is generally no longer available if it has been captured by Watch.
Copy
var s = Watch.GetOriginalFileName();
Watch.GetPDFEditObject Is used to manipulate PDF files using the AlambicEdit library, which allows Workflow to access, create or modify PDF files. For more information see AlambicEdit API reference.
Watch.GetPreferences

Returns a JSON string containing the preferences for the OL Connect Server and Workflow's HTTP Server, NodeJS Server and SMTP Server.

Copy

dim JSONString

JSONString = Watch.GetPreferences();

Watch.GetResources

 

Retrieves a specific type of Connect resources when it is passed a file extension (e.g. "OL-template") or all Connect resources when it is passed an empty string.

Copy
var allTemplates = Watch.GetResources("OL-template");
Watch.GetVariable Retrieves the content of a local or global variable by name.
Copy
var s = Watch.GetVariable("MyVariable");
Watch.InstallResource Is used to copy or unpack resources, such as a Connect Designer template, Data Mapping Configuration, package file, etc., from the supplied path to the Connect Documents folder.
Copy
Watch.InstallResource("c:\myfile.ol-package");
Watch.Log Writes to the Workflow log file, or the message window when in debug - can accept multiple log levels from 1 (red) to 4 (gray).
Copy
Watch.Log("Hello, World!", 3);
Watch.SetJobInfo Writes the value of a string to a numbered job info.
Copy
Watch.SetJobInfo(9, "Job info 9 Value");
Watch.SetVariable Writes the value of a string to a local or global variable by name.
Copy
Watch.SetVariable("MyVariable", "Hello World!");
Watch.Sleep Pauses all processing for X milliseconds.
Copy
Watch.Sleep(1000);