Common Advanced Printer Scripting Errors

KB Home   |   Common Advanced Printer Scripting Errors

Main.ScriptingErrors History

Hide minor edits - Show changes to output

November 16, 2018, at 05:28 PM by Aaron Pouliot - Added category - Print Scripting
Changed line 44 from:
''Categories:'' [[Category.PrintScripting]]
to:
''Categories:'' [[Category.PrintScripting|+]]
November 16, 2018, at 07:07 AM by Aaron Pouliot - Added category - Print Scripting
Changed line 44 from:
''Categories:'' [[Category.PrintScripting]],
to:
''Categories:'' [[Category.PrintScripting]]
November 16, 2018, at 07:07 AM by Aaron Pouliot - Added category - Print Scripting
Changed line 44 from:
''Categories:'' [[Category.Troubleshooting+]],
to:
''Categories:'' [[Category.PrintScripting]],
Changed lines 13-14 from:
'''Solution:''' The above error indicates that the script can not find the function specified. In this specific case, the [[http://en.wikipedia.org/wiki/Letter_case|Letter Case]] of the function name is incorrect. Instead of inputs.user.isingroup() you will need to use inputs.user.isInGroup
to:
'''Solution:''' The above error indicates that the script can not find the function specified. In this specific case, the [[http://en.wikipedia.org/wiki/Letter_case|Letter Case]] of the function name is incorrect. Instead of [@inputs.user.isingroup()@] you will need to use [@inputs.user.isInGroup@]
Added lines 1-46:
(:title 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. %red%(printer-script#16)%% This indicates line 16 is where the problem is.

!! `TypeError: Cannot find function

'''Example:''' %red%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 [[http://en.wikipedia.org/wiki/Letter_case|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:''' %red%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 November 16, 2018, at 05:28 PM
Printable View   |   Article History   |   Edit Article