Hi, I am trying to generate pdf reports through bullzip printer written in codeunit, which I am trying to call from webservice. But it gives error of "Callback Functions are not allowed". I can run the codeunit in navision from other objects and report is printing in pdf ok, I can also use webservice to call other simple function of the same codeunit, which returns just string.
So I am very sure that it has some problem with the line of code Report.RunModal. Has anybody had any such experience or solution.
I also tried pdfcreator, but with that I am getting timeout error, with it also I am able to print ok through running codeunit in nav. In both cases, unfortunately I can't debug, as it is cross application.
Thanks,
Rushabh.
0
Comments
http://blogs.msdn.com/nav-reporting/arc ... rvice.aspx
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Frankly, I am not much known of how to make customized report to get the pdf output, so I may be wrong, I will also see that further. One question, does making the report available on RTC and functionality such as saveaspdf, does it have any impact on the output of original report?
Thanks for your help.
Does anybody have such issue, as per Rashad's suggestion, saveaspdf is possible, but why report.run doesn't work from webservice. Does it require any security setting or something like that. Because to enable saveaspdf I will require to design convert the customized reports into the role tailored layout. I prefer instead printing to pdf printers and displaying it. Is it possible to print report from webservice? Becaues I couldn't do it with either bullzip or pdfcreator, both gives error of 'soapexception:Callback functions are not allowed'(which I believe doesn't give any information as it is run across platform so debugger won't have any exact message).
In fact I can print the reports without problem directly by running codeunit function within nav, it doesn't work only through webservice.
Thanks in advance.
I guess they didn't implement in webservice to call the classic client so they only option you have is to create the layout.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
thanks for your reply, but actually I am just trying to use the codeunit in nav to print report to pdfprinter. So why should it require RTC layout for it. What I am trying to do is define function in the codeunit with printer of either bullzip or pdfcreator. Set the printer properties and report.runmodal or report.run.
And it looks like that is some issue with printing i.e. Report.runmodal or run statement. As if I comment that there is no error in initializing the automation controls or returning string. And as I said I can run and print this function from within another object(codeunit) in NAV alright.
I prefer to use pdfprinter instead of saveaspdf, as it will remove any efforts to define layout in rtc, which I am not known.
Any idea?
Thanks.
Instead of printing your report, try to print a standard 2009 report, you probably won't get the error.
You have to learn how to create layout.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Sorry to eat your time again, but I am getting error even with standard report. like 301. I can use saveaspdf but not report.runmodal, for your reference I am copying my codeunit and .net application(small windows application with just one button) code here.
Bullzip
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);
FileDirectory := 'C:\NavRep\';
FileName := 'bullzip.pdf';
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);
REPORT.RUNMODAL(301,FALSE,FALSE);
TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1000);
TimeOut := TimeOut + 1;
END;
EXIT(FileDirectory + FileName);
pdfcreator----
IF ISCLEAR(PdfCreator) THEN
CREATE(PdfCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
FileDirectory := 'C:\';
FileName := 'example.pdf';
PDFCreatorError := PdfCreator.cError;
IF PdfCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + PDFCreatorError.Description);
PDFCreatorOption := PdfCreator.cOptions;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
PDFCreatorOption.AutosaveDirectory := FileDirectory;
PDFCreatorOption.AutosaveFormat := 0; //PDF file, you can also save in other formats
PDFCreatorOption.AutosaveFilename := FileName;
PdfCreator.cOptions := PDFCreatorOption;
PdfCreator.cClearCache();
DefaultPrinter := PdfCreator.cDefaultPrinter;
PdfCreator.cDefaultPrinter := 'PDFCreator';
PdfCreator.cPrinterStop := FALSE;
REPORT.RUNMODAL(301,FALSE,TRUE);
//REPORT.SAVEASPDF(301,FileDirectory+FileName);
//REPORT.SAVEASPDF(301,'C:\abc.pdf');
EXIT(FileDirectory+ FileName);
.net code----
BullzipS.BullZipPrint bz = new WindowsApplication1.BullzipS.BullZipPrint();
bz.UseDefaultCredentials = true;
bz.Url = "http://localhost:7047/DynamicsNAV/WS/CompanyName/Codeunit/BullZipPrint";
string bzstring = bz.PrintCustStatement();
MessageBox.Show(bzstring);
// The following is for pdfcreator
//AccessNAVReports rs = new AccessNAVReports();
//rs.UseDefaultCredentials = true;
//rs.Url = "http://localhost:7047/DynamicsNAV/WS/Companyname/Codeunit/AccessNAVReports";
//string reportpath = rs.PrintStatement();
//MessageBox.Show(reportpath);
And I can run the webservice and do anything except report.run.
thanks,
Rushabh.
Did anyone ever get around the "Callback functions are not allowed" problem...???
Thanks
I'm not crazy !!! Just ask my toaster...
.
SaveasPDF is the only solution.
you have to change your code to
if isservicetier then
report.safeasPDF
else
Report.runmodal
You can report it as a bug to MS or suggest it as a new feature.
They probably will answer it as by design.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Ahhh yes... the good old catch-all...
I'm not crazy !!! Just ask my toaster...
.
You can't use the UI when accessing from a webservice call.
Look here: http://msdn.microsoft.com/en-us/library/dd301080.aspx
It would be nice if there were a variable to set to say "don't show any UI", kind of like :
IF GUIALLOWED THEN
SETNOGUITOSHOW;
or
IF ISSERVICETIER THEN
SETNOGUITOSHOW;
I'm not crazy !!! Just ask my toaster...
.
I think the problem is that when NAV is running reports (just process or with page outputs), it runs GUI threads anyway, so thats why it fails. I guess margin calculations and dpis are involved and thats why the GUI comes in.
(Just a theory)
While there are no request pages or anything like that it still has to generate the output... the fact that I'm just trying to print the thing is probably neither here nor there...
I'm not crazy !!! Just ask my toaster...
.
You can add a line to On Init just in case you have something in the request form:
CurrReport.USEREQUESTFORM(GUIALLOWED);
or
CurrReport.USEREQUESTFORM(ISSERVICETIER);
Have your WebService code spawn/enable a Job Queue job, that will then run the report. Since the Job Queue is running under a NAS, it isn't running the same "session" as your WebService, and thus doesn't have the "no callbacks" restriction. I use PDFCreator/Bullzip like this ALL the time with Reports fired off by Job Queue, and it works a treat!