This month we have decided to try and fire Ross again, Last time we tried he found out a bit early by looking at the print archives, this time, we have created a script so HR can opt to disable print archiving for jobs that they believe are sensitive. To find out how we did this grab a cup of coffee and continue reading.

After looking through the <a href="http://www.papercut.com/products/ng/manual/common/topics/script-print-api.html" target="_blank">Print Script API documentation</a>, I noticed a useful method: <strong>actions.job.disableArchiving()</strong>, This will allow us to disable the archiving so that sensitive or confidential documents are not viewable by other users.

<img class="aligncenter wp-image-2388 size-full" src="https://staging.selectec.com/wp-content/uploads/2016/05/archiving_disabled.png" alt="archiving_disabled" width="902" height="212" />

To start setting this up we are going to create three variables one for the group, one for the message to show in a pop-up and the last one will contain the message to show as a job comment.
<pre class="">var GROUP = "HR";
var MESSAGE = "Do you want to disable archiving for this job?";
var COMMENT = "This job was considered sensitive and archiving was disabled";</pre>
Next we need to check if the user is in the group we have set in the variable and display a popup box. There a few different types of popup box we can create which will be covered in future articles. For this month we are only interested in a simple Yes or No box. We will also need to use the response from the box in the script so we will need to set it to a variable.
<pre class="">if (inputs.user.isInGroup(GROUP)) {
    var RESP = actions.client.promptYesNo( MESSAGE );
    // More code will follow
}</pre>
After that we now have a window that will pop up when a user in the HR group prints it should look something like this:

&nbsp;

At the moment it doesn't matter what option is selected as we are not checking the response, The first one we will want to check is if they click Yes the value that will be returned is YES so it will just be a simple case of checking to see if RESP matches that value. We will also want to add the <strong>actions.job.disableArchiving()</strong> method and provide a handy comment to go along with the job so we can see why there is no archived copy of the job this is done using <strong>actions.job.addComment()</strong>.
<pre class="">if (RESP == "YES"){
    actions.job.disableArchiving();
    actions.job.addComment(COMMENT);
    return;
}</pre>
The only thing left to do now is deal with nothing being pressed this is referred to as TIMEOUT, We are not bothered with what happens when they click No as we just want the job to print out like normal, so we don't need to set anything for it.
<pre class="">if (RESP == "TIMEOUT") {
    actions.job.cancel();
    return;
}</pre>
That is it for this month and as always the complete print script is below and don't worry we didn't let anyone go in the making of this script.

If you have your own requirements for a print script and you don’t have the time or in-house experience to make it you can find out how we can help you by sending an email to our sales team at <a href="mailto:sales@selectec.co.uk">sales@selectec.co.uk</a>
<pre class="">/*
* Allow a group of users to disable Archiving
*
* Read more at https://selectec.co.uk/script-of-the-month-8-disable-print-archiving/
*/
function printJobHook( inputs, actions ) {

    var GROUP = "HR";
    var MESSAGE = "Do you want to disable archiving for this job?";
    var COMMENT = "This job was considered sensitive and archiving was disabled";

    if (!inputs.job.isAnalysisComplete) {
        return;
    }

    if (inputs.user.isInGroup(GROUP)) {
        var RESP = actions.client.promptYesNo( MESSAGE );

        if (RESP == "TIMEOUT") {
            actions.job.cancel();
            return;
        }

        if (RESP == "YES"){
            actions.job.disableArchiving();
            actions.job.addComment(COMMENT);
            return;
        }
    }
}</pre>