Using Microsoft Dynamics NAV 2009
I am getting the same error message whenever I debug my C#, which consumes a published web service codeunit. The codeunit takes parameters and designed to run either another codeunit, or a report. When passing parameters to run a codeunit through the C# program, it runs successfully, however if the parameters are changed to run a report instead, I get my error as stated above.
I have researched and removed some problems which I may believe to be the problem. I have removed and function which would cause a dialog box, or I have used GUIALLOWED for them.
I believe the problem may be this. If I try to run a report in the classic client, I am required to select a company before doing this action. This is different for running a codeunit as I am not asked for a company to select. My theory is to add some code into the C# console application, so that before it runs the report, it selects a company beforehand.
I am struggling to solve this error, so any help or advice is welcomed. I am still new to web services.
0
Answers
If it's a report which prints something (i.e. not ProcessingOnly) then have you created an RDLC report layout for it?
I don't think you can run a classic report in a web service as it will be running on the NST (middle tier) when called via a web service.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
It is a report that prints. In the C/AL of the report, it produces a .txt when run.
To your final point, I'm not sure if I made myself completely clear. The published webservice is a codeunit, but takes parameters in it's C/AL method to run codeunits/reports, which are available in the classic client, without the object being run published as websevice. The webservice runs codeunits fine, but does it fail for reports for what you said in your answer?
Yes, the dialog box is the only reason why I am getting an error. When running a report normally in the classic client, I am prompted for a company name. I am not asked for a company when running a codeunit, so I believe this is where my problem lies.
I am thinking that this is a problem which must be solved in NAV as my C# program is only designed to pass on parameters, so it can't handle an user interaction.If this is right, how and where would I solve this issue?
Have you seen the questions I asked in my initial reply above?
Also another thought... are you using any automation server variables in your report? If you are then it could be that you are instantiating them to run on the client (3rd parameter of the CREATE function) - this would also result in the error you are getting.
Related to the above is are you using the "Excel Buffer" in your report as this uses client side automation objects.
I can't send a screen shot right now, but I will later. I do agree with your first point, that it should include the company in the URL.
Yes, I use the create function to create an output file when a report is run. This would classify as an automation server variable, correct? However, when I run parameters to run a codeunit instead of a report in the C# application, it is able to create a file without any errors.
Another thought, are you using the "3-Tier Automation Mgt." codeunit - note that this also uses client side Automation objects in some functions such as SilentUpload or DownloadToFile etc...
P.S. If it's not the above then if you can include the code in your report then it might be a little easier to spot the problem.
// create file
CLEAR(fOut);
fOut.TEXTMODE(TRUE);
IF ISSERVICETIER THEN BEGIN
tTempFileName := cu3TierAutMgt.ServerTempFileName('','dat');
fOut.CREATE(tTempFileName);
END ELSE BEGIN
IF NOT fOut.CREATE(tFileName) THEN BEGIN
CurrReport.QUIT;
EXIT;
END;
END;
The CREATE function is for a file, but you mentioned the 3-Tier Automation Mgt. CU. This does exist in the code. Is this the problem? If so, what are your suggestions?
1) Rem out the code above
2) Rem out any code that uses the fOut variable (e.g. fOut.WRITETEXT(...))
3) Leave all other code as is
...with the above changes do you still get the same error?
1) When testing the 2 different scenarios - are you logged into windows using the same account? If not then it sounds like the account giving the error does not have rights to create the file
2) There must be some other code assigning a value to the tTempFileName variable - what is the code. It's the path here that is likely causing the error
3) What is the code in the ServerTempFileName() function in the "3-Tier Automation Mgt." codeunit, it should be...
2) There is this code, but I have removed it as it uses a CU containing automation objects.
IF ISSERVICETIER THEN BEGIN
cu3TierAutMgt.DownloadToFile(tTempFileName,tFileName);
ERASE(tTempFileName);
END;
3) I don't have the permissions to view the code in CUs unfortunately so I can't tell you at this stage.
Sorry for the late reply, but I have been busy.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!