Options

Causing a Report to Print through Web Services

jreynoldsjreynolds Member Posts: 175
edited 2012-01-06 in NAV Three Tier
I’m trying to use web services to get a NAV report to print. Is this possible?

I have written a codeunit with a single function (RunReport) that has only a single line of code:
REPORT.RUN(REPORT::"Inventory - List",FALSE,TRUE);
The codeunit has been added to the Web Service table with a name of TestReport and the Published field set to TRUE.

In Visual Studio I have created a Console Application and added the appropriate web reference. The C# code is shown below.
using System;
using System.Collections.Generic;
using System.Text;

namespace TestReport
{
    using WebService;

    class Program
    {
        static void Main(string[] args)
        {
            TestReport rpt = new TestReport();

            rpt.UseDefaultCredentials = true;
            rpt.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Codeunit/TestReport";
            rpt.RunReport();
        }
    }
}
Running the application in Visual Studio gives an error - "Callback functions are not allowed."

Comments

  • Options
    wakestarwakestar Member Posts: 207
    smells like "user interaction" ... print dialog box maybe?
  • Options
    jreynoldsjreynolds Member Posts: 175
    I suspect that you may be right. The running of the report is run without using the request page. When I run the same function directly from the role tailored client there is a status box that is displayed counting off the pages as they are generated. Perhaps this is causing problems with the web service?
  • Options
    wakestarwakestar Member Posts: 207
    try this:

    go to the report properties and set ShowPrintStatus to No
  • Options
    jreynoldsjreynolds Member Posts: 175
    This did stop the status box from displaying in the RTC, but web services is still not liking it.
  • Options
    wakestarwakestar Member Posts: 207
    download the documentation from https://mbs.microsoft.com/customersourc ... page=false
    and check chapter 5, page 33
  • Options
    jreynoldsjreynolds Member Posts: 175
    Thanks for the tip. I had already discovered that SAVEASPDF would work. Now I have to figure out how to get the PDF file to print on the desired printer.
  • Options
    primeapprimeap Member Posts: 37
    jreynolds wrote:
    I’m trying to use web services to get a NAV report to print. Is this possible?

    Running the application in Visual Studio gives an error - "Callback functions are not allowed."


    Try to set the Report to "processing only"..
  • Options
    deV.chdeV.ch Member Posts: 543
    Last Message was from 2009 so i gues its solved in some way :D

    But to pick that one up: processing only doesn't work because then it wouldn't print. If you want to print you can't set this property to true.

    The only solution i know to do this is to save the report as pdf and use a proxy application to print that pdf with a pdf reader (Proxy application may not be needed if you use a domain account other then Network Service for the webservice-service).
  • Options
    primeapprimeap Member Posts: 37
    ok.. you are right but what do you mean by that?
    deV.ch wrote:
    (Proxy application may not be needed if you use a domain account other then Network Service for the webservice-service).
  • Options
    deV.chdeV.ch Member Posts: 543
    If you ran the webservice (The service itself) unter a domain account, (lets say, user1) then you can call the pdf viewer application (for printing) from within nav, because it will execute under that account and therefore you are able to add printers to that account.
    If you are not aware of, it's not possible (or atleast not easy and not recomended) to add printers to "Network Service" account (on which the service will run at default).
Sign In or Register to comment.