Print Scripting with Job Ticketing

KB Home   |   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.

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.


Keywords: Job Ticketing, Print Scripting

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on June 25, 2018, at 04:24 AM
Printable View   |   Article History   |   Edit Article