Knowledgebase: PaperCut > Scripting
Common Advanced Printer Scripting Errors
Last modified on 15 August 2020 09:33 PM

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)


function printJobHook(inputs, actions) {
    if (!inputs.job.isAnalysisComplete) 
    // No job details yet so 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") {

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