Print Routing based on the day of the week

17 Jan 2011

When I added support for conditional actions in Print Distributor I thought most customers would want to test on the size of the document and maybe the document name. I was quite wrong, you have been finding all sorts of interesting applications for conditions.

To set a condition on an Action select the action then click on the Condition button. A window will open that lets you enter an new expression or remove an existing expression. These expressions are tested before the action is run.

The expressions are based on VBScript, you can enter boolean values (true or false), tests (<, <=, <>, >, >=, =) and even call functions such as InStr to search for a string. All the document information is available including fields like UserName and DocumentName.

One request we have seen regularly comes from large restaurants, many of them will close down part of their kitchen in quiet periods. What they want is to route their customers orders to different printers during those quiet periods.

The logic is something like this:

Virtual Printer 1: Print to physical printer 1

Virtual Printer 2: If is weekend then print to physical printer 2

If is weekday then print to physical printer 1

The first printer should be straight forward, lets look at how we setup the second virtual printer with the conditions. The first stage is to create our virtual printer and add two Reprint actions, one pointing to printer 1, the second to printer 2.

Select the first action then click on the condition button and enter the expression:

WeekDay(PrintDate) = 1 Or WeekDay(PrintDate) = 7

The PrintDate field contains the date the print was generated and the WeekDay function extracts the day of the week from the date. The result of WeekDay is a number from 1 to 7 corresponding to the days Sunday to Saturday. This example is going to be true for weekends. Next we need to add the opposite expression to the second action:

WeekDay(PrintDate) <> 1 And WeekDay(PrintDate) <> 7

You should end up with your actions looking like this:

The help file contains details on all the fields and functions available, if you get stuck then send us a message and we will happily walk you through the process.