Best way to get printer name from XML in Workflow

Hello,

I have a Workflow (shown below) that takes an input XML file, runs it through some Javascript (step 4) and then takes the output and puts it in a DataMapper (step 7).

image

I need to add something near step 13 to read a printer name from the XML file or the DataMapper and then send Print Content to that printer.

Could you please tell me the most straightforward way to do this?

From what I’ve read I think the simplest thing to do is to read the printer name in step 4 and then add it to the Data Repository, then read the printer name from the Data Repository near step 13.

Thanks!

Create a Local Variable. Read your printer name or IP address from your XML into that variable (Set Job Infos and Variables). If you’re creating a “Windows Output” printer queue, you can use the local variable in the “Printer queue” setting. Your “Send to Printer Queue” output plugin will resolve the name/ip.

Ok great, thank you very much!

For future reference, here’s the Javascript to find the printer network id tag in the XML and set JobInfo variable 1:

var fso2 = new ActiveXObject("Scripting.FileSystemObject");

var inputFile = fso2.OpenTextFile(Watch.GetJobFilename(), 1);
var sFile = inputFile.ReadAll();
inputFile.Close();

var position = sFile.indexOf("<Field_PrinterNetworkId>");
var position2 = sFile.indexOf("</Field_PrinterNetworkId>", position);
var sValue = sFile.substring(position + 24, position2);
Watch.SetJobInfo(1, sValue);

And here’s how you would access the JobInfo variable in a later print task:

@automation.JobInfo1@

Enjoy!

When I tried to use @automation.JobInfo1@ in the Printer Queue input box on the Windows Output - Printer Queue Output task it did not work.

But using %1 did work:

Have fun!