Print Scripting with Job Ticketing

If you’ve got Job Ticketing installed and running, there are a couple of handy print scripts that you can use to let our users know about this new exciting option for print submission and to ensure that print jobs are sent to your print rooms.

Update - December 2019

Both of the print scripts described below are now available as recipes within PaperCut MF (v18.3 or later). Simply choose to import a recipe and you will find the two options below ready to use.

Job Ticketing - Cancel large jobs and prompt user to upload to Job Ticketing
This recipe will cancel printing once a specified number of pages is reached. The user is informed that their job has been cancelled and prompted to click the link in the popup to upload their documents to Job Ticketing.

Job Ticketing - Display once-off popup message
This popup message is displayed to the user at the time of printing to inform users about Job Ticketing. Users can dismiss this message and the message will not be displayed again. Note: The pop-up message appears only when the User Client is actively running.

Cancel large jobs from printing and direct your users to Job Ticketing

This print script will stop users from printing over a specified number of pages. If the print job exceeds this number, a pop-up box will be displayed with a link for the user to use Job Ticketing for their print job.

The admin can specify the maximum number of pages in this script.

What do I need to do?

1. Copy and Paste the script below into PaperCut MF’s advanced scripting area (for more info: https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/script.html)

/*
* Cancel large jobs with  a pop-up message to use Job Ticketing
*
* A user printing a large job is advised their job will be cancelled
* and they will need to use Job Ticketing
*/
function printJobHook(inputs, actions) {

  /*
  * This print hook will need access to all job details
  * so return if full job analysis is not yet complete.
  * The only job details that are available before analysis
  * are metadata such as username, printer name, and date.
  *
  * See reference documentation for full explanation.
  */
  if (!inputs.job.isAnalysisComplete) {
    // No job details yet so return.
    return;
  }

  var LIMIT             = 100; // Redirect jobs over 100 pages.

  if (inputs.job.totalPages > LIMIT) {
    /*
    * Job is larger than our page limit, we will cancel the job and ask the user to upload it to Job Ticketing
    * Send a message to the user to advise and include a link to the Job Ticketing Upload.
    * Note: Tailor this message to suit your use-case
    */

    var response = actions.client.promptOK(
      "<html>"
      + "<div style='width:400px; height:240px; padding: 10px; color:#FFFFFF; "
      + "    background-color:#00AE5A;'>"
      + "  <div style='padding: 10px; font-weight: bold; font-size: 18px; text-align: center;'>"
      + "    Print Policy Alert<br>"
      + "    <img src='http://%PC_SERVER%/custom/job-ticketing-logo.png'>"
      + "  </div>"
      + "  <div style='font-size: 10px; text-align: center;'>"
      + "   This print job is above the maximum number of pages"
      + "   that can be printed to <br>the Find Me print queue.<br><br>"
      + "   Please submit your document to Job Ticketing using the link below:<br><br>"
      + "  </div>"
      + "  <div style='font-size: 12px; font-weight: bold; text-align: center;'>"
      + "  <a href='http://localhost:9191/job-ticketing' style='color:white;text-decoration: none'><u>Job Ticketing</u></a><br>"
      + "  </div>"
      + "</div><br>"
      + "<div align='center'>"
      + "</div>"
      + "</html>",{'hideJobDetails': true, 'dialogTitle': "Your job has been cancelled", 'dialogDesc' : "Your print job has been cancelled, please see below for details"});  

    actions.job.cancelAndLog("Job exceeded maximum number of pages. Cancelled, user directed to Job Ticketing.");
    return;
  }
}

2a. Add a custom image that will be displayed in the pop-up box, in the PaperCut NG/MF installation directory: <server>/custom/ folder and adjust the script to reflect the name of the image.

2b. You can download and use this image for the pop up:

3. Check that the script correctly references the URL for your Job Ticketing environment.

One time pop up to let users know about Job Ticketing

If your organization is new to Job Ticketing, this is a print script that you can use to let users know they can now use Job Ticketing to submit their jobs. This pop up appears only when the User Client is actively running and once users dismiss the pop-up message, it will not be displayed again.

What do I need to do?

1. Copy and Paste the script below into PaperCut MF’s advanced scripting area (for more info: https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/script.html)

/*
* Display a one-off message to users to let them know about Job Ticketing
*/
function printJobHook(inputs, actions) {

  /*
  * This print hook will need access to all job details
  * so return if full job analysis is not yet complete.
  * The only job details that are available before analysis
  * are metadata such as username, printer name, and date.
  *
  * See reference documentation for full explanation.
  */
  if (!inputs.job.isAnalysisComplete) { return; }

  // Get the current value of the user property "job-ticketing-displayed" and write to variable "viewed"
  var viewed = inputs.user.getProperty("job-ticketing-displayed");

  // If viewed is null, then the key doesn't exist
  if (viewed == null) {
    // Display message to user
    actions.client.promptOK(

      "<html>"
      + "<div style='width:400px; height:260px; padding: 10px; color:#FFFFFF; "
      + "    background-color:#00AE5A;'>"
      + "  <div style='padding: 10px; font-weight: bold; font-size: 18px; text-align: center;'>"
      + "    Did you know?<br>"
      + "    <img src='http://%PC_SERVER%/custom/job-ticketing-logo.png'>"
      + "  </div>"
      + "  <div style='font-size: 10px; text-align: center;'>"
      + "   Did you know we now have a new way for you to submit jobs via Job Ticketing?<br><br>"
      + "   With Job Ticketing you can submit your print jobs"
      + "   and keep track of your previous orders.<br><br>"
      + "   Click the link below to login and check it out now.<br><br>"
      + "  </div>"
      + "  <div style='font-size: 12px; font-weight: bold; text-align: center;'>"
      + "  <a href='http://localhost:9191/job-ticketing' style='color:white;text-decoration: none'><u>Job Ticketing</u></a><br>"
      + "  </div>"
      + "</div><br>"
      + "<div align='center'>"
      + "</div>"
      + "</html>",{'hideJobDetails': true, 'dialogTitle': "Did you know?", 'dialogDesc' : "Your print job has been sent, but have you heard about Job Ticketing?"})

  )

  // Set the property against the user when job is completed (even if it was cancelled). This stops the message being displayed again.
  actions.user.onCompletionSaveProperty("job-ticketing-displayed", "yes", {'saveWhenCancelled' : true})

    }}

2a. Add a custom image that will be displayed in the pop-up box, in the PaperCut NG/MF installation directory: <server>/custom/ folder and adjust the script to reflect the name of the image.

2b. You can download and use this image for the pop up:

3. Check that the script correctly references the URL for your Job Ticketing environment.


Categories: How-to Articles, Scripting and APIs, Print Jobs

Keywords: Job Ticketing, Print Scripting, mf-only

Comments