In this article it is described how you can use InterFormNG2 to select the printer based on a user profile found in the input file, that was sent to InterFormNG2.
As a simple example we consider a node in the XML file found via this path: /root/user.
We want InterFormNG2 to merge the input file with a template and print the result on a printer, that is selected via a table as below:
User | Printer |
Allan | PRT01 |
Brian | PRT02 |
Christine | PRT02 |
<Fallback printer for anyone else> | PRT03 |
The setup is, that for the 3 named users the printer on the right should be selected. If the user found is not any of those, then the fall back printer (PRT03 above) should be selected.
First we build a translation file as a simple UTF-8 encoded text file with this as the contents:
Allan=PRT01
Brian=PRT02
Christine=PRT02
*OTHERWISE*=PRT03
The special key value, *OTHERWISE* sets the value (PRT03) if a key for lookup is not found (i.e. we search for a user, that is not Allan, Brian or Christine).
This file can e.g. be created with Notepad or Notepad++. We save the save file as PrinterLookup.properties.
The extension, .properties is required and you should avoid any underscore in the file name.
This XPath function returns the printer to use for the user, Brian:
ng:translation('PrinterLookup','Brian','')
Which returns the value, PRT02.
This function:
ng:translation('PrinterLookup','Mr.X','')
Returns PRT03 as 'Mr.X' is not found in the translation file.
You can e.g. verify this in a text element in a template.
For the implementation in the workflow we can now use this function in the workflow like below:
The workflow editor might warn about a non-existing printer (depending on the selected selected sample file in the workflow) like below: