NAS Report Error

nverma
Member Posts: 396
A report needs to be run using NAS, therefore, we cannot have any popup windows (i.e. message, request windows, error, etc).
If I were to run the report (50006) manually, in the request window, I need to input a PostingDate. Since we are running the report using NAS, I need to suppress this request form and apply the posting date manually. Therefore in order to do this, in the report I created a new function called: SetDefaults which contains a parameter called 'DefaultDate' of date type. In the function I have the following code:
PostingDate := Default Date;
I am running this report using a codeunit. In the Codeunit, I defined a variable called Report1 (with report type variable). Then I wrote the following line of code:
Report1.SetDefault(TODAY);
REPORT.RUN(50006, FALSE);
The request form is suppressed, however, the PostingDate does not contain TODAY.
Another thing to notice is that, in Report1 (50006) there is a check in OnPreReport trigger:
If PostingDate = 0D then
IF GUIALLOWED THEN
error('please enter the date')
I am not really sure how to pass the date from the codeunit and make the report remember the value. I thought this is how I would do it. What am I missing? The Event Viewer always contains, please enter the date.
If I were to run the report (50006) manually, in the request window, I need to input a PostingDate. Since we are running the report using NAS, I need to suppress this request form and apply the posting date manually. Therefore in order to do this, in the report I created a new function called: SetDefaults which contains a parameter called 'DefaultDate' of date type. In the function I have the following code:
PostingDate := Default Date;
I am running this report using a codeunit. In the Codeunit, I defined a variable called Report1 (with report type variable). Then I wrote the following line of code:
Report1.SetDefault(TODAY);
REPORT.RUN(50006, FALSE);
The request form is suppressed, however, the PostingDate does not contain TODAY.
Another thing to notice is that, in Report1 (50006) there is a check in OnPreReport trigger:
If PostingDate = 0D then
IF GUIALLOWED THEN
error('please enter the date')
I am not really sure how to pass the date from the codeunit and make the report remember the value. I thought this is how I would do it. What am I missing? The Event Viewer always contains, please enter the date.
0
Answers
-
The problem is that you need to change the way you call the report
From this:
Report1.SetDefault(TODAY);
REPORT.RUN(50006, FALSE);
To this:
Report1.SetDefault(TODAY);
Report1.USEREQUESTFORM(FALSE);
Report1.RUN;0 -
I never knew you could turn off request from that way. I learned something new today.
Thank you so much. That worked. =D> \:D/0
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