An instance of the Occurrence class represents a single item in a job's occurrence trail, and allows retrieving the occurrence's attributes. See job occurrence trail.
Returns the moment in time when this occurrence happened. The class of the returned Date object is specific to the scripting environment in use.
Returns the occurrence type as a string (one of "Detected", "Produced", "Moved", "Duplicated", "Processed" or "Failed").
Returns the module or type of flow element causing this occurrence (same as the module attribute in a log message).
Returns the name of the flow causing this occurrence.
Returns the name of the flow element (as displayed in the canvas) causing this occurrence.
Returns an indication of the origin of the job before it was injected in the flow by this occurrence. For example, a Submit point writes the absolute path of the original job (on the client machine) in this attribute. This attribute is meaningful only for ‘Produced' occurrence types. This function returns the empty string for other occurrence types.
Returns the name of the folder (as displayed in the canvas) that received the job as a result of this occurrence. This attribute is meaningful only for ‘Produced', ‘Moved', and ‘Processed' occurrence types. This function returns the empty string for other occurrence types.
Returns the type of the connection that carried the job as a result of this occurrence, as one of the following strings: "Noop", "Move", "Filter", "Traffic-data", Traffic-log", "Traffic-datawithlog". This attribute is meaningful only for ‘Produced', ‘Moved', and ‘Processed' occurrence types. This function returns the empty string for other occurrence types.
Returns the success level of the job when carried over a traffic-light connection, as an integer (success = 1, warning = 2, error = 3). This attribute is meaningful only if the job was actually carried over a traffic-light connection. If the getConnectionType() does not return a string that starts with "Traffic", getSuccessLevel() returns zero.
Returns the basic message associated with this occurrence, without argument replacement or localization. The basic message is not intended for human consumption, but can be used in a script to discriminate between various causes of an error, for example (similar to an error code).
This attribute is meaningful only for ‘Failed' occurrence types. This function returns the empty string for other occurrence types.
Returns the message associated with this occurrence after argument replacement and localization. The localized message is intended for human consumption.
This attribute is meaningful only for ‘Failed' occurrence types. This function returns the empty string for other occurrence types.
/*
* logging the info of the most recent occurrence
*/
//create logfile
var logPath = job.createPathWithName("log.txt");
var f = new File(logPath);
f.open(File.WriteOnly);
//get most recent occurence (no argument)
var occ = job.getMostRecentOccurrence();
//write info to file
f.writeLine("Date: " + occ.getTimeStamp());
f.writeLine("Type: " + occ.getType());
f.writeLine("Module: " + occ.getModule());
f.writeLine("Element: " + occ.getElement());
f.writeLine("Flow: " + occ.getFlow());
f.writeLine("Origin: " + occ.getOrigin());
f.writeLine("OutFolder: " + occ.getOutFolder());
f.writeLine("ConnType: " + occ.getConnectionType());
f.writeLine("Successlvl: " + occ.getSuccessLevel());
f.writeLine("BasicMsg: " + occ.getBasicMessage());
f.writeLine("LocalizedMsg: " + occ.getLocalizedMessage());
//save and send to single outgoing connection
f.close();
job.sendToSingle(logPath);