Wednesday 6 February 2013

Running batch report in AX2009 (batch printing)


Since the change of AX2009 batch framework, printing of report through batch can be done through two methods:
- Printing from server (to printer or file)
- Printing from client (the legacy batch processing)

Prerequisites: For both of the method, there're some mandatory setup:
  1. Enable any of the AOS that you want to make it as batch AOS
    (Administration -> Setup -> Server configuration)
  2. Create batch group for printing.
    Eg. One for client printing and one for server printing.
    (Administration -> Setup -> Batch groups)
  3. Add the batch group created in #2 into the AOS enabled for batch processing (in #1)

Printing from server (print to printer)
  • Enable the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab.
  • Enable the 'Connect to printers on the server' settings at Dynamics AX (client) Configuration Utility under the 'Connection' tab
  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for server printing
    > Click on the "Option" and select the server printer. Server printers are prefix with 'AOS:'


Printing from server (print to file)
  • Enable the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab.

    *Although you're printing to file, but you still need to enable this.
  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for server printing
    > Click on the "Option" and select 'File', then ensure the file name is a UNC path (Eg.\\serverName\directory) else you'll get an error.

    *After this job is added to the batch, you can check it at 'Basic > Inquiries > Batch job'. Click on the 'View tasks', notice that the 'Run location' is "Server". If your 'Run location' is "Client", then you might have selected a client printer or your report class method 'runsImpersonated()' has been overwritten to return "false".

Printing from client (through legacy batch processing)
  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for client printing
    > Click on the "Option" and select the client printer
  • Run the legacy batch processing (Basic > Periodic > Batch > Processing)

    *After this job is added to the batch, you can check it at Basic > Inquiries > Batch job. Click on the 'View tasks', look at the printing job/task, it will change from "Waiting" to "Ready", then to "Executing". Also notice that the 'Run location' is "Client". The legacy batch processing require the task to be in "Ready" status, this field cannot be changed manually, it is automatically changed if you've done step #3 in the prerequisites (it might not change immediately, give it some time then refresh it and look at the status again).
Some common errors:
  • Use of printers on the server is not allowed





















  • Resolution: Ensure the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab is checked.
  • Target file must be in UNC format

  • Resolution: Ensure when you select 'File' as the output, the 'File name' is UNC path. Eg. \\serverName\directory
  • @"\\SON15882\D$\Test\Cust.txt" 
  • Selected printer is not an AOS printer




















Resolution: Install the printer driver on the server.
Sometimes there're confusion regarding AOS printer and shared printer.
For printing to works in batch mode (running from server), the printer has to be AOS printer, which the printer is "Installed" as printer on the AOS host server, not "Connect" as shared printer.

No comments:

Post a Comment