<h2 style="text-align: left;">PaperCut Print Script of the month</h2>
This months script is a nice and easy one and something that we thought was included in the recipes that come with PaperCut but we couldn't see it. The goal is to inform users of the jobs cost is over a certain amount and give them the option to carry on printing or cancel the job, Once you have found a hot cup of coffee we can get to work.

&nbsp;

The script is almost the same as the "Confirm jobs with a high number of pages" recipe included but with the slight change of focusing on the cost instead of the pages. The first thing we will want to do is work out what our cost limit will be and to set the message to show to the user.
<pre>var COST = 1.0;
var MESSAGE = "This job costs over £" + COST + " are you sure you want to print it?";</pre>
Now we need to check to see if the print job costs more than the cost set above which we can do using the inputs.job.cost method.
<pre class="">if (inputs.job.cost &gt;= COST) {
  // This will only run if the jobs cost is more than our limit
}</pre>
We know that we have the right jobs now so we can show the prompt to ask the user if they want to print making sure that we set the result to a variable, so we know when to cancel the job.
<pre>var response = actions.client.promptPrintCancel(MESSAGE);</pre>
The response variable will now contain one of 3 options PRINT, CANCEL and TIMEOUT. PRINT and CANCEL are based on the 2 buttons that appear and TIMEOUT will occur if nothing is selected at all. All we need to do from here is cancel the job if the response is either CANCEL or TIMEOUT if the user selects print we don't want to do anything so we can just ignore it.
<pre>if (response == "CANCEL" || response == "TIMEOUT") {
  // cancel the job then exit the script
  actions.job.cancel();
  return;
}</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 sending an email to our sales team at <a href="mailto:sales@selectec.com">sales@selectec.com</a></h4>
<pre class="">/*
* Ask users to confirm the print job if over a certain cost
*
* Read more at https://staging.selectec.com/script-of-the-month-10-confirm-jobs-high-cost/
*/
function printJobHook(inputs,actions) {
  // What is our limit for alerts?
  var COST = 1.0;
  // This is the message we will show the users
  var MESSAGE = "This job costs over £" + COST + " are you sure you want to print it?";

  if (!inputs.job.isAnalysisComplete) {
    return;
  }

  // Check the job cost
  if (inputs.job.cost &gt;= COST) {
    // Show the prompt and set the response to the response variable
    var response = actions.client.promptPrintCancel(MESSAGE);
    // If user clicked Cancel or there was a timeout
    if (response == "CANCEL" || response == "TIMEOUT") {
      // Cancel the job and exit the script
      actions.job.cancel();
      return;
    }
    // User pressed print so we will let the job go
  }

}</pre>