OL Learn

Print a report of processes using a printer


#1

I would like to create a report showing a particular printer and all the processes that print to it.
How do I create this type of report in Planetpress?
Thank you


#2

Well, first of all, welcome to our online community :slight_smile:

It is possible, however not very simple since the file containing all your Workflow processes information wasn’t conceive for this particular situation.

The file is ppwatch.cfg and can be found here:

C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch

Now, at first, I would suggest you open it in Notepad++ or any good data editor to check upon the encoding of the file. By default the encoding should be UTF-8 but could be different if some of your processes contains characters that aren’t UTF-8 compatible (like a script). If that is the case, simply run the config.cfg file through a new process in Workflow while using the plugin Translator.

You will also need to add the encoding in the root node of the file. Simply use a Search & Replace plugin to replace this: <?xml version="1.0" ?> by this: <?xml version="1.0" encoding="utf-8"?>

Once done, create a new XML Datamapper and load the config.cfg file. Set it up to Use root element.

Now, in your config.cfg file, you will find each processes under the following structure:

<WatchConfig>
   <ProcessList>
     <Process>
     <Process>

For the following explanation, when I mention Node (in bold), I mean the name of the XML node in the config.cfg file. When I speak of node, simply, it is an XML node common term (I know, a little confusing but remember my first statement…it was not designed to be read by something else than Workflow Configurator

Inside each process, look for the node named Node. Each of these node correspond to a step in your Workflow process. Please note that a branch is also a step, therefore any step under it would become a node Node in your config.cfg file. It would look something like this:

<WatchConfig>
   <ProcessList>
     <Process>
       <Node>   //Your input step
       <Node>   //Your branch
         <Node> //Some step in your branch
         <Node> //...
         <Node> //Your output step
       <Node>   //Some other step
       <Node>   //...
       <Node>   //Your output step
     </Process>
     <Process>
     </Process>
   </ProcessList>
<WatchConfig>

Of course, this is an overly simplified explanation of the file structure, but you get the idea.

So, in the Node node that are your output, you need to look for a nested node named Plugin which value is either OutputGDI (a Print Using a Windows Driver output step) or InternalOutputPrinter (a Printer Queue Output output step).

For OutputGDI, there is a following node named Config which hold the Windows printer driver configuration as it was setup in your Workflow process step. This is where you will find the name of the printer queue. The value of that node is in an XML format but need to be passed through a DecodeComponentURI javascript function to be properly read.

For InternalOutputPrinter, there is a sibling node named PrinterList which holds a unique alpha-numeric value that refers to a printer as defined in your Workflow Configuration. That unique ID can be referred to a higher level node named PrinterList, which can be found at the same level as node ProcessList.

Once there, look for the following structure:

<PrinterList>
  <Printer>
    <UniqueName>

It is the value of the node UniqueName that you will compare to the value of node PrinterList previously mentioned.

From there, you could attempt some logic to map all processes and related printer into a Datamapper and print a report out of it.

This answer was just to put you in the proper context and guide you toward a possible solution. Unless some other users of this forum have attempted such endeavour and are willing to share the solution.

Hope that help.

Use Phil’s post below as it is way more performing than mine. :thinking::smile:


Printing Workflow Configuration
#3

There’s no native functionality to do this, but you can still create a report by being a bit creative…

You can use the DataMapper to extract that information from the Workflow Config. You will then be able to design the report you want, based on the information extracted.

For instance, let’s say the Printer Queue name in Workflow is ACMEPrinter.

  • Open the DataMapper and create a new XML configuration. Use your Workflow Configuration file as the sample data file and tick the Use root element option.
  • In the XML Viewer, right-click on the ProcessList element and select Add Goto
  • Right-click again and select Add Extraction. In the properties for the Extraction step, change the XPath statement to //PrinterList/Printer[Name=‘ACMEPrinter’]/UniqueName (making sure you use the actual printer name). Rename the extracted field to PrinterID.
  • In the XML viewer again, right-click on the same element and select Add Repeat

So now you have a field named PrinterID which contains the internal ID for that specific printer queue. You can now search for all processes that contain a reference to that ID.

Now here’s the fun part. You need your Repeat loop to only iterate on all processes that use the target printer. To do that, you set the Repeat type to For Each and then set the Collection to the following XPATH statement:

=./Process[descendant::Node[PrinterList=’{record.fields.PrinterID}’]]

At that stage, the DataMapper should already show you on which Processes it will be iterating. Because you specified the proper XPATH statement, there’s no need to iterate through all the nodes or use conditions to see if they match what you’re looking for: XPATH does that for you out of the box.

So finally, inside the loop, you can extract the process name by simply specifying the following XPATH:

./Name

That’s pretty much it as far as the extraction process is concerned. Obviously, you’ll have to create your own Template for the report, but that shouldn’t be much of a problem now that you have a detail table containing all the Process names in which the target printer is used.

Have fun!