PaperCut Print Script

PaperCut Print Script of the Month #11 Setting queue timeout for WebPrint

PaperCut Print Script of the month

This month we are going to look at making sure the jobs sent by users over the weekend through WebPrint are not cancelled by the hold/release settings. Grab a cup of coffee and we can be started.

The first step will be working out how we can tell the source of the print job. Luckily there is a method that does this for us inputs.job.jobSourceName() this would return the name of the user’s machine, but if you are using Google Cloud Print it will be GOOGLE_CLOUD_PRINT, For WebPrint it will be WEB_PRINT and if you are using Email to Print, it will be EMAIL_PRINTING. Now we know what it does and what we should be looking for we can start building our PaperCut Print Script.

if (inputs.job.jobSourceName == "WEB_PRINT") {
  // More code will go here
}

Inside this if statement we will only be dealing with Web Print jobs so all we need to do now is override the system set Hold/Release Timeout option which we can do using actions.job.setHoldReleaseTimeout() the minimum value for this is 5 minutes but we want to set it a little bit higher to maybe 2 days (2880 minutes) which cover us for any jobs printed over the weekend. With this option in place our if block will now look something like this.

if (inputs.job.jobSourceName == "WEB_PRINT") {
  actions.job.setHoldReleaseTimeout(2880);
}

Now we could stop here, but this setting would also impact jobs printed during the week which we don’t want to happen. To get around this, we need to take the lines above and make use of Javascript date methods so we can detect if it is the weekend or not, To do this we will check the Date.GetDay() for a 6 or a 0 where 6 is Saturday and 0 is Sunday.

var today = new Date();
if (today.getDay() == 6 || today.getDay() == 0) {
  // The rest of the code will go here
}

That is it for this month and as always the complete PaperCut Print Script is below. If you have your own requirements for a print script and you don’t have the time or in-house experience to make it you can find out how we can help you by getting in touch with our sales team.

Get in touch today | sales@selectec.com

/*
* Hold Web Print jobs for longer over the weekend
*
* Read more at http://selectec.com/papercut-print-script-month-11-setting-queue-timeout-webprint/
*/

function printJobHook(inputs, actions) {
  var today = new Date();
  
  // If job is from Web Print
  if (inputs.job.jobSourceName == "WEB_PRINT") {
    // If today is Saturday or Sunday
    if (today.getDay() == 6 || today.getDay() == 0) {
      // Set hold timeout to 2880 minutes
      actions.job.setHoldReleaseTimeout(2880);
    }
  }
}