mshill Posted June 13, 2017 Posted June 13, 2017 Hi All Trying to create a script that limits the number of copies a student can print, I have amended the number of pages script to try and achieve this but it doesn;t seem to work. Has any of the Papercut gurus got any idea why it is not doing anything. /* * Cancel large print jobs sent by students * * Members of the Students group are only allowed to print up to 100 pages. Jobs * larger than this will be canceled with a notification. This recipe demonstrates * group-level restrictions. */ function printJobHook(inputs, actions) { var RESTRICTED_GROUP = 'Students'; var COPY_LIMIT = '3'; /* * This script needs to check the number of pages in the job, so return here * unless job analysis is 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; } /* * If the user belongs to the disallowed group and the job has more pages than * the limit, cancel the job and send a notification (if they are running the * client software). */ if (inputs.user.isInGroup(RESTRICTED_GROUP)) { if (inputs.job.copies > COPY_LIMIT) { // in the restricted group and printing over the limit, cancel the job actions.job.cancelAndLog('Not allowed to print more than ' + COPY_LIMIT + ' copies.'); // send message to the user's client tool actions.client.sendMessage('Your print job has been canceled because the ' + 'number of copies (' + inputs.job.copies + ') was more than the maximum allowed (' + COPY_LIMIT + ')'); // log a message for debugging actions.log.debug('Canceling job from user ' + inputs.job.username + ' in ' + RESTRICTED_GROUP + ' group because the number of copies (' + inputs.job.copies + ') was more than the maximum allowed (' + COPY_LIMIT + ')'); } } } Regards
mshill Posted June 13, 2017 Author Posted June 13, 2017 I now have this working, but any idea how this could be set so it also works when scanning the document and printing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now