Advanced Scripting: Conditionally Suppress Pop-up

KB Home   |   Advanced Scripting: Conditionally Suppress Pop-up

In education and corporate firms, it is very common to use account selection popups. It allows users to select the account they want to print to.

These organizations also do not want to annoy their users with an unnecessary number of pop-ups and instead only want to track jobs over a certain page count, or dollar amount. For example: Do not display shared account selection popup if the number of pages is less than 10 and charge to personal account. This can be achieved by using Advanced Scripting.

Scripts are available under Printers → [Name of the printer] → Scripting. These scripts are very useful when such customization need to be implemented. This feature makes PaperCut a powerful tool and can be customized to meet requirements of different organizations.

The account selection popups are displayed before the analysis is even complete which is what makes it tricky to suppress the popup. To be able to do this there is a small trick will you need to follow. You will need to add “actions.job.chargeToPersonalAccount();” to the section where analysis is not complete.

actions.job.chargeToPersonalAccount() is an API that is used to disable any client popups and account selection, and to charge the job to the user’s personal account.

See the script below:

function printJobHook(inputs, actions) {

  if (!inputs.job.isAnalysisComplete) {

    actions.job.chargeToPersonalAccount();
    return;
  }

  if (inputs.job.totalPages < 10) { 
    // Charge to the personal account
    actions.job.chargeToPersonalAccount();
    // Or maybe charge to a single shared account
  }
  // Account Selection will still show 
}

Categories: Scripting


Keywords: customizing, Print Scripting, display popup

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 December 11, 2015, at 09:13 PM
Printable View   |   Article History   |   Edit Article