I have been tasked with combining two if statements in Js
for a papercut script. It is a print management software. I have everything I need I believe in the script below. The problem is combining these two if's into one statement I believe. I am not familiar with Javascript as well as I am with python. I am hoping for some help in rearranging this script to do as stated below.
PaperCut print script API reference
Goal:
Only do the cost center popup if they print jobs 10+ pages, otherwise just automatically charge the job to the firm non-billable (ADM-3900) account. If the job is 50+ pages, redirect it from the HP to the larger copier. In this case, from test_printer3 to Copier – Color.
/*
* Redirect large jobs without confirmation
*
* Users printing jobs larger than the defined number of pages have their jobs
* automatically redirected to another printer or virtual queue.
* This can be used to redirect large jobs from slower or high cost printers
* to more efficient or faster high volume printers.
*/
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.
*/
/*
* NOTE: The high-volume printer must be compatible with the source printer.
* i.e. use the same printer language like PCL or Postscript.
* If this is a virtual queue, all printers in the queue must use
* the same printer language.
*/
if (!inputs.job.isAnalysisComplete) {
// No job details yet so return.
return;
actions.job.chargeToPersonalAccount();
return;
if (inputs.job.totalPages < 10) {
// Charge to the firm non-bill account
actions.job.chargeToSharedAccount(ADM-3900);
}
// Account Selection will still show
}
var LIMIT = 5; // Redirect jobs over 5 pages.
var HIGH_VOL_PRINTER = "Copier - Color";
if (inputs.job.totalPages > LIMIT) {
/*
* Specify actions.job.bypassReleaseQueue() if you wish to bypass the release queue
* on the original printer the job was sent to. (Otherwise if held at the target,
* the job will need to be released from two different queues before it will print.)
*/
actions.job.bypassReleaseQueue();
/*
* Job is larger than our page limit, so redirect to high-volume printer,
* and send a message to the user.
* Specify "allowHoldAtTarget":true to allow the job to be held at the hold/release
* queue for the high-volume printer, if one is defined.
*/
actions.job.redirect(HIGH_VOL_PRINTER, {allowHoldAtTarget: true});
// Notify the user that the job was automatically redirected.
actions.client.sendMessage(
"The print job was over " + LIMIT + " pages and was sent to "
+ " printer: " + HIGH_VOL_PRINTER + ".");
// Record that the job was redirected in the application log.
actions.log.info("Large job redirected from printer '" + inputs.job.printerName
+ "' to printer '" + HIGH_VOL_PRINTER + "'.");
}
}