Combining Script Recipes

KB Home   |   Combining Script Recipes

Main.CombiningScripts History

Hide minor edits - Show changes to output

November 21, 2018, at 07:12 AM by Aaron Pouliot - Set category to Print Scripting
Changed line 37 from:
''Categories:'' [[Category.Scripting | +]]
to:
''Categories:'' [[Category.PrintScripting | +]]
July 10, 2014, at 06:51 PM by TimG - Clarified where to put the final printJobHook caller.
Changed line 19 from:
* '''Below''' both the two renamed recipes add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
to:
* '''Below''' the two renamed recipes (at the very end of the script text) add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
May 17, 2011, at 03:23 AM by peter - Fixed link
Changed lines 3-4 from:
It is possible to combine [[https://www.papercut.com/tour/print-quotas/|Advanced Scripts]]. Someone with an understanding of JavaScript should be able take parts from two or more existing scripts and combine them.
to:
It is possible to combine [[https://www.papercut.com/tour/advanced-scripting/|Advanced Scripts]]. Someone with an understanding of JavaScript should be able take parts from two or more existing scripts and combine them.
May 17, 2011, at 03:01 AM by peter - tidied up draft text
Changed lines 3-4 from:
It is possible to combine [[https://www.papercut.com/tour/print-quotas/|Advanced Scripts]]. Someone with an understanding of JavaScript should be able take parts from two or more existing script and combine them.
to:
It is possible to combine [[https://www.papercut.com/tour/print-quotas/|Advanced Scripts]]. Someone with an understanding of JavaScript should be able take parts from two or more existing scripts and combine them.
Changed line 19 from:
* '''Below''' both the two rename recipes add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
to:
* '''Below''' both the two renamed recipes add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
Changed line 34 from:
If the combined script still does not work then there may be some JavaScript knowledge required. In this case you discuss your script with someone who knows JavaScript.
to:
If the combined script still does not work then there may be some JavaScript knowledge required. In this case you should discuss your script with someone who knows JavaScript.
Deleted lines 35-36:
https://www.papercut.com/kb/Main/Miscellaneous
May 17, 2011, at 02:59 AM by peter - Fixed typo
Changed lines 5-6 from:
This article is intended to help people who are not JavaScript programmers combine two recipes that one is run after the other. It is not a replacement for understanding JavaScript.
to:
This article is intended to help people who are not JavaScript programmers combine two recipes so they run one after the other. It is not a replacement for understanding JavaScript.
Changed lines 14-15 from:
PaperCut calls printJobHook once per job. If you wish to have two recipes be called then you must call them both from one printJobHook() function.
to:
PaperCut calls printJobHook once per print job. If you wish to have two recipes called for a job then you must call them both from one printJobHook() function.
May 17, 2011, at 02:56 AM by peter - Createed
Added lines 1-41:
(:title Combining Script Recipes:)

It is possible to combine [[https://www.papercut.com/tour/print-quotas/|Advanced Scripts]]. Someone with an understanding of JavaScript should be able take parts from two or more existing script and combine them.

This article is intended to help people who are not JavaScript programmers combine two recipes that one is run after the other. It is not a replacement for understanding JavaScript.

A typical Advanced Script contains one printJobHook() function
[@
    function printJobHook(inputs, actions) {
      ... some JavaScript code ...
    }
@]

PaperCut calls printJobHook once per job. If you wish to have two recipes be called then you must call them both from one printJobHook() function.

A simple way to do this is
* Copy the first recipe into your script and rename its printJobHook to printJobHook1.
* Copy the second recipe into your script and rename its printJobHook to printJobHook2.
* '''Below''' both the two rename recipes add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
[@
        function printJobHook(inputs, actions) {
            printJobHook1(inputs, actions);
            printJobHook2(inputs, actions);
        }
@]
If both recipes work individually on your printer and it makes sense to call recipe 2 after recipe 1 then this combined script should do that for you.

!!Troubleshooting a Combined Script
If your combined script does not work on your printer then
* Check that recipe 1 alone works on your printer. You can do this by saving the combined script in a text editor and re-importing recipe 1.
* Check that recipe 2 alone works on your printer. You can do this by saving the combined script in a text editor and re-importing recipe 2.
* Confirm that it makes sense to call recipe 2 after recipe 1.

If the combined script still does not work then there may be some JavaScript knowledge required. In this case you discuss your script with someone who knows JavaScript.
 
https://www.papercut.com/kb/Main/Miscellaneous

----
''Categories:'' [[Category.Scripting | +]]
----
[-Keywords: combine, combining, script, scripts, 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 November 21, 2018, at 07:12 AM
Printable View   |   Article History   |   Edit Article