Though, I can run report by making a new function in report itself to initialize report and then run it. I call that function from codeunit as per requirement. Even, report run fine but the only issue is that if I do not want to show request page; then report does not run. It shows on RTC that it is printing report but it do not run report & nothing happens.
I am using code :
On Codeunit :-
>> SalesInvoiceHeaderReport.InitializeVariablesFunction('103001');
On Report :- (On "InitializeVariablesFunction" (ReportID) )
>> "Sales Invoice Header".RESET;
>> "Sales Invoice Header".SETRANGE("No.",ReportID);
>> REPORT.RUNMODAL(206,FALSE,TRUE,"Sales Invoice Header");
I pass report ID from codeunit and then put setrange.
>>Reports run fine when I use -> REPORT.RUNMODAL(206,TRUE,TRUE,"Sales Invoice Header");
>>Reports does not run fine when I use -> REPORT.RUNMODAL(206,FALSE,TRUE,"Sales Invoice Header");
0
Answers
Please suggest me a way around.
Requirement is that the specific report should be run during the posting routine of a particular record.
Just filter the record in the codeunit and pass it with the Report.Run Call. No need for the variable function, as I see it.
Yes I'm running report from within the report.
I am not able to filter record from codeunit as when I run it from codeunit, I don't know why but filter gets clear automatically.
If filters don't work. Then call the report from its variable after calling the function.
Variable.run; (not report.run)
Report does not show output and go for default printer option set in your local PC.
For example, default printer in my PC is local printer, so running report it start printing and does not show output on the RTC window.
SalesInvoiceHeaderReport.RUN;
OR
SalesInvoiceHeaderReport.GET('103001');
REPORT.RUN(206, FALSE, TRUE, SalesInvoiceHeaderReport);
Both should work, unless you clear the filter in Report.
Why can't you use much simpler construction in your codeunit, like below, and get rid of InitializeVariablesFunction from the report ?
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
I tried your solution as well. It again go to print and does not show output on RTC.
On the other hand, if I make "Request Window" property set to true, everything works fine.
But I don't need request window as this report will be running at the time of posting a record.
If you want to have a preview you have to use REPORT.RUNMODAL(.., TRUE, TRUE,...) or REPORT.RUN(.., TRUE, TRUE,...)
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03