G2 Fall report names PaperCut #1 in Print

Choose your language

Choose your login

Contact us

Help Center menu

PRODUCT MANUALS

PaperCut NG & PaperCut MF Manual

PRODUCTS FEATURED

Troubleshooting print scripts

The Advanced Scripting window has some simple debugging tools such as logging and runtime error reporting.

Where possible the error message indicates the line number on which the error was found and the relevant line is highlighted.

Error messages are classed into two groups:

Scripting syntax errors

These are detected and displayed when you click Apply. The error message indicates the line number on which the error was found and the relevant line is highlighted. The script does not save until all syntax errors are addressed.

Scripting runtime errors

These are errors that occur when a script is executed. To see the errors, refresh the Scripting tab. The error message indicates the line number on which the error was found and the relevant line is highlighted.

Where possible the error message indicates the line number on which the error was found and the relevant line is highlighted:

Runtime errors are also logged and displayed on the App Log tab:

Debugging (troubleshooting) common scripting errors

Hint: Any error should also have a line number indicating where the issue was. e.g. (printer-script#16) indicates line 16 is where the problem is.

Example 1: TypeError: Cannot find function

e.g. Error in "printJobHook" - TypeError: Cannot find function isingroup in object User[username=john.doe,fullName=,restricted=false]. (printer-script#16)

Code:

if (inputs.user.isingroup("Students")) {

Solution:

The above error indicates that the script can not find the function specified. In this specific case, the Letter Case of the function name is incorrect. Instead of inputs.user.isingroup() you will need to use inputs.user.isInGroup

Example 2: The script failed to validate

e.g. The script failed to validate, check the script syntax: invalid return (printer-script#17)

Code:

function printJobHook(inputs, actions) {
    if (!inputs.job.isAnalysisComplete) 
    // No job details yet so return.
    return;
}

if (inputs.job.isColor) {
  var response = actions.client.promptPrintCancel(
    "<html>This print job is <span style='color:red'><b>color</b></span>"
    + " and costs <b>" + inputs.utils.formatCost(inputs.job.cost)
    + "</b>.  You can save money by printing the job in grayscale.<br><br>" 
    + "Do you want to print this job?</html>",
    {"dialogTitle" : "Color print job", 
     "dialogDesc"  : "Consider printing in grayscale to reduce costs"});
  if (response == "CANCEL" || response == "TIMEOUT") {
    actions.job.cancel();
    return;
  }
}
}

Solution:

This one is a bit harder to diagnose. The error indicates that the return; on line 17 is invalid. This is caused by a missing { on line 2. if (!inputs.job.isAnalysisComplete) should be if (!inputs.job.isAnalysisComplete) {

Comments