Common Advanced Printer Scripting Errors

KB Home   |   Common Advanced Printer Scripting Errors

This KB article will attempt to provide examples and solutions for some of the more common scripting errors that our customers experience.

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

TypeError: Cannot find function

Example: 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

The script failed to validate

Example: 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) {


Categories: Category.Troubleshooting+,


Keywords: scripting errors, script error, scripting help, error scripting, script wont work

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on January 13, 2012, at 12:21 AM
Printable View   |   Article History   |   Edit Article