<h2>PaperCut Print Script of the Month</h2>
We like to think we have a sense of humour around here, and what better way to keep ourselves entertained than by sending print jobs to the wrong printer for the day? Grab a cup of tea (only joking. Coffee is the only choice...) and we can start with the PaperCut scripting fun.

This month's script is going to make use of an array to hold the printer names you want to include. If you want to read more about arrays, you can check <a href="/script-of-the-month/script-of-the-month-3-random-quote/">Script of the Month #3</a>.
<pre class="">var printers = ['science_room','maths_room','english_room'];</pre>
&nbsp;

Now the PaperCut method we are going to use will allow us to redirect the job to a printer and also recalculate the cost, of course, you will want to make sure you are using the <a href="https://www.papercut.com/help/manuals/ng-mf/applicationserver/find-me-global-print-driver/" rel="noopener">PaperCut Global Print Driver</a> or that you are using the universal driver for your printers.

The method is below and you can see it requires one parameter which is the printer name, there are also some options we can set for this one to set if the job should be held or if we should recalculate the cost.
<pre class="">actions.job.redirect(printerName[, options])</pre>
&nbsp;

We are only interested in the recalculate cost option, so this changes the method to be like the example below.
<pre class="">actions.job.redirect(printerName, {recalculateCost: true});</pre>
&nbsp;

Now all we need to do is randomly get a printer from the array just like we did with the <a href="https://staging.selectec.com/script-of-the-month-3-random-quote/">random quote script</a> back in December, Now we have our complete line which should look like below and we can get everything put together.
<pre class="">actions.job.redirect(printers[ Math.floor( Math.random() * printers.length ) ], {recalculateCost: true});</pre>
<h3></h3>
<h3 style="line-height: 1.5em;">As always the complete PaperCut print script is below for you to use. 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 sending an email to our sales team at <a href="mailto:sales@selectec.com">sales@selectec.com</a></h3>
&nbsp;
<pre class="">/*
 * Send print jobs to random printer
 *
 * Read more at https://staging.selectec.com/script-of-the-month-6-april-fools-2016/
 */
function printJobHook( inputs, actions ) {
 
 if (!inputs.job.isAnalysisComplete) {
 // No job details yet so return.
 return;
 }
 
 // Array of printers
 var printers = ['science_room','maths_room','english_room'];
 actions.job.redirect(printers[ Math.floor( Math.random() * printers.length ) ], {recalculateCost: true});
}</pre>