web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Printing on AOS with a AIF-Webservice

(0) ShareShare
ReportReport
Posted on by

Hi all,

I have created an AIF web service to enable an external application to print specific reports in AX.
Calling the web service works fine.
"Only" the call of the print routine (to a shared printer on the server on which the AOS service is running) creates an error message in the AIF exceptions:

Exception: Warning
Module: AIF
Child System: AifRequestProcessor-executeServiceOperation
Exception Message: There is no default printer selected.

For testing, I've logged in with the AOS service-user on Windows and select a default printer. But that did not help.

- In the config of the server and client printing to AOS is enabled.
- The AOS service is restarted.
- The printer is selectable in the AX client to print (with the prefix "AOS").
- When I call the web service method through a test job printing works.

Does anyone else have any idea what I could try?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Ahmad Profile Picture
    2,465 User Group Leader on at

    Hi Sascha,

    This is a classic problem that many of us ran into when writing our AIF web services.  It almost always occurs because the application pool, which the AIF Web Service is configured under, is not a domain account or there is no user profile that has permissions for the default printer that the application pool is running under.  

    Thankfully, the steps to diagnose this are laid out for us already.  See this classically written blog post on how to diagnose and fix it:  

    blogs.msdn.com/.../printer-defaults-to-letter-instead-of-a4-how-ax-finds-the-default-printer.aspx

    The authors will explain the default printer problem towards the end of the post. That should get you up and running but let me know if it doesn't.  

  • Community Member Profile Picture
    on at

    Thanks for your answer.

    Ok. If I understand this blog correctly the user from the Application Pool will be used for the print management. But this user have also the necessary permissions on the printer. I will try to log in with the application user on the aos server and select an default printer and try it again.

  • Community Member Profile Picture
    on at

    Now I logged in with the application-pool-user and selected an default printer. But I still get the message, that there is no default printer...

  • Verified answer
    Brandon Ahmad Profile Picture
    2,465 User Group Leader on at

    Hi Sascha,

    Sorry that I missed your follow up question. I have to run, but I promise to come back and answer this tonight if no one else has taken it.  Someone may take it, however.  You need to make change to the user profile for the application pool account that the service is running under where you select the correct printer.  Then, you might need to clear the cache (yet again) so that this is reflected.  

    I'll come back and explain how to do that if no one else takes this and does so.  Got to run and take some certification exams to keep my Microsoft Training License but I'll take care of this tonight.  Again, I apologize for missing the follow up question.  

  • Verified answer
    Brandon Ahmad Profile Picture
    2,465 User Group Leader on at

    Hi Sascha,

    Thanks for waiting so long.  Okay, now to set the default printer may fool you.  You need to do this through group policy.  I had remembered reading this somewhere and had to go back and find the document.  And I found it.  

    Check Page 132 on the Dynamics AX Implementation Guide:

    go.microsoft.com/fwlink

    See in the authors blog, the author calls a windows function to open up the printer properties.  This means that the printer had to already exist and there was most likely a default group policy for setting the default printer to where that user account running the code could access the policy.  

    The reason why the authors fix worked in going to a domain account is because of the fact that the domain account already had a default printer.  Therefore, Windows Server Administration needs tobe done in this case.  

    But what if default group policy fails to actually set a default printer for that account???  You can manually force it in the registry or fix the group policy issue by having your windows network administrator read this:

    social.technet.microsoft.com/.../4fc28b59-afb4-44ea-b6fd-8c7dd558cbca

    You are getting pretty close.  That should help you out.  Keep me updated and let me know if you get it fixed with that.  You are almost there.  Just get that windows account to get a default printer listed in it.  

  • Community Member Profile Picture
    on at

    Thanks again for your answer.

    Now I see some light at the end of the tunnel... :-)

    For testing I changed the following users to my domain-account:

    - Application Pool User in IIS.

    - The client-credentials in the .config for my Webservice-Test-Application.

    - The Business Connector Proxy-User in AX (2009).

    Then I set a default printer on the server where the IIS is running.

    Now the AX-Report prints on that default printer.

    The "only" thing I have to check is how to define in ax which printer should be used.

    At the moment I try to set the printsettings for the report like this:

       printJobSettings = SysPrintOptions::newPrintJobSettingsOnServer();

       printJobSettings.deviceName("Name of the Printer", ClassRunMode::Server);

       printJobSettings.setTarget(PrintMedium::Printer);

    With the result, that the report is printed on the default printer

    I also tried this:

       printJobSettings = new PrintJobSettings();

       printJobSettings.deviceName("Name of the Printer", ClassRunMode::Client);

       printJobSettings.setTarget(PrintMedium::Printer);

    With the result that nothing will be printed.

  • Verified answer
    Community Member Profile Picture
    on at

    Ok. Hard job. I think I retire... :-)

    Now it works. The printjobsettings in AX had to be defined on client side ("new PrintJobSettings()" instead of "SysPrintOptions::newPrintJobSettingsOnServer()").

    And the name of the printer in

    printJobSettings.deviceName("Name of the Printer", ClassRunMode::Client);

    has to be the "network name" of the printer.

    For example:

    I have to assign "\\Servername\Printername" instead of "Printername on Servername" like displayed in the "Devices and Printers" - window on Win2008.

    Again I thank you a lot Brandon.

    May the force be with you.

  • Brandon Ahmad Profile Picture
    2,465 User Group Leader on at

    I just love a post like this.  I've spent years writing WCF services, and I'm really happy to see that in Dynamics AX now.  I think that this post will help a great deal of people and I thank you for documenting your steps to fix it.  :)  

  • saman0suke Profile Picture
    2,894 on at

    I'm having this exact same problem, everytime I try to print a report in AX from a C# site, it does nothing, while it works if I run the same method from inside AX, the account setup for SSRS is also used as Business Proxy Account, do I need to use that one in the application pool, and where else? I would appreciate specific details, thank you.

  • Community Member Profile Picture
    on at

    Hello,

    how do you try to print this report?

    Do you call a static method in AX over AIF?

    If so, will the method in ax executed and only the printing failed?

    Or do you have the problem that not even the method in ax is executed?

    Which AX-Version do you use?

    Can you post the web.config from your Webservice?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans