How can I run a Report object from a codeunit while request page set to false by parameter?

atpiyush
Member Posts: 12
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");
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
-
I am able to save the report as PDF, send as attachment in email but not able to run it while the "Request Page" parameter is false for "REPORT.RUNMODAL" function.
Please suggest me a way around.
Requirement is that the specific report should be run during the posting routine of a particular record.0 -
Hi Juhl,
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.0 -
If I call the report using report object variable, I am not able to run the report if I make the 'Request Page' property set to false using code.
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.0 -
SalesInvoiceHeaderReport.InitializeVariablesFunction('103001');
SalesInvoiceHeaderReport.RUN;
OR
SalesInvoiceHeaderReport.GET('103001');
REPORT.RUN(206, FALSE, TRUE, SalesInvoiceHeaderReport);
Both should work, unless you clear the filter in Report.Follow me on my blog juhl.blog1 -
Hi,
Why can't you use much simpler construction in your codeunit, like below, and get rid of InitializeVariablesFunction from the report ?SalesInvoiceHeader.GET('103001'); SalesInvoiceHeader.SETRECFILTER; //without this it will print everyting. REPORT.RUNMODAL(206, FALSE, TRUE, SalesInvoiceHeader);
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-032 -
Hi Slawek,
I tried your solution as well. It again go to print and does not show output on RTC.0 -
Problem is that it is not showing output on RTC if I use any code samples above suggested by you guys.
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.0 -
REPORT.RUNMODAL(.., FALSE, TRUE,...) is not supposed to show any output on the RTC. It prints directly to the printer.
If you want to have a preview you have to use REPORT.RUNMODAL(.., TRUE, TRUE,...) or REPORT.RUN(.., TRUE, TRUE,...)
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions