<h2 style="text-align: left; line-height: 1.5em;">PaperCut Print Script of the month</h2>
<h4 style="text-align: left; line-height: 1.5em;">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.</h4>
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.
<pre class="">if (inputs.job.jobSourceName == "WEB_PRINT") {
  // More code will go here
}
</pre>
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.
<pre class="">if (inputs.job.jobSourceName == "WEB_PRINT") {
  actions.job.setHoldReleaseTimeout(2880);
}</pre>
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.
<pre class="">var today = new Date();
if (today.getDay() == 6 || today.getDay() == 0) {
  // The rest of the code will go here
}</pre>
<h4></h4>
<h4></h4>
<h4 style="text-align: left; line-height: 1.5em;">That is it for this month and as always the complete PaperCut Print Script is below. If you have your own requirements for a <a href="https://staging.selectec.com/select/scripting/">print script</a> 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.</h4>
<div class="well well-lg">
<h3 style="text-align: center;">Get in touch today | <a href="mailto:sales@selectec.com">sales@selectec.com</a></h3>
</div>
<pre>/*
* Hold Web Print jobs for longer over the weekend
*
* Read more at https://staging.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);
    }
  }
}
</pre>