NAS Report Error

nvermanverma 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.

Answers

  • ftorneroftornero Member Posts: 524
    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;
  • nvermanverma Member Posts: 396
    I never knew you could turn off request from that way. I learned something new today.

    Thank you so much. That worked. =D> \:D/
Sign In or Register to comment.