Changed main DataItem on a report, and now cannot call using Report.RUN

I am working on NAV 5.0 SP1.

I had created a custom report with 2 DataItems: Sales Header and Integer (indented).

Through requirements I needed to change the Report to be: Sales Shipment Header and Integer (indented).

Now I cannot run the report when I call it as follows:

REPORT.RUN(50044,FALSE,TRUE,SalesShipmentHeader);

The error message is:


Microsoft Dynamics NAV

The Commercial Invoice for Customs report does not have a DataItem that uses the table (Table 110 Sales Shipment Header) specified in the function SetTableView.


OK

Thanks in advance for any help.

Hi Ben,

Have you change the report 50044 to run off the Sales Shipment Header?

Yeah, you won’t just get that error for no reason. What is the first data item in report 50044?

The DataItems in Report 50044 are:

Sales Shipment Header
Sales Shipment Line
Integer

I am able to run the report by selecting the report and running it, then entering in (or selecting from the list) a filter for No. on the Sales Shipment Header tab.

I have now recreated the report from scratch using the Sales Shipment Header, and I still get the same error.

So there must something wrong with the calling code. From which object are you trying to call your report?

The call happens from a custom table (Carrier Bill of Lading) that acts as a header for Sales Shipment Lines from multiple Sales Shipment Headers. I have added a field on the Sales Shipment Line table that is the key field for this table (Carrier Bill of Lading).

Here is the full code from “Carrier Bill of Lading”.PrintPaperWork

GetSalesShipmentHeaders;

IF SSHdr.FINDSET THEN BEGIN
REPEAT
SSHdr.SETRANGE(“No.”,SSHdr.“No.”);

REPORT.RUN(50044,FALSE,TRUE,SSHdr);

SSHdr.SETRANGE(“No.”);
UNTIL SSHdr.NEXT = 0;
END;

The function GetSalesShipmentHeaders creates a list in SSHdr of all Sales Shipment Header records that are referenced in Sales Shipment Lines that have the same value as the Key field in the current table.

The issue is that the variable I was passing was Temporary. I changed it to pass a non-temp variable and it is fine now. Thanks for all your suggestions.

Wow. I had no idea you couldn’t pass a temporary record to a report like that. I guess in a way it makes sense, though. Still, it would be nice if it mentioned it in the client help.

This solution helped me out today!

Spent more than 4 hours to figure out what could be wrong. Checked and rechecked the table ID of the record that was passed in the report.runmodal and checked and rechecked the main DataItem used in the report. They were identical and still this error came up when running the report.runmodal statement.

Looked if I was missing a property somewhere and so on … nothing wrong!

What I finally did was simply create a new report with the same main DataItem, put some fields on a body section and modified the calling code to run this new report instead. Same problem. WTF! Than I created a new codeunit with some lines of code in it that are similar to the lines of code from the original object the report was being run in. Worked fine. At that moment I knew that there must be something different that causes this problem, but still could not find it.

Late in the evening my mind was still spinning and I had to find the cause. I already googled the internet in an earlier moment, but no results found that were pointing in the correct direction … until now. Once I read this I had to try this myself and indeed: passing a record of a TEMP table to a report causes this error!

The problem I had was that the TEMP table was defined in some other object and passed via via via as VAR parameter to a codeunit in which it was passed to the report.runmodal so I was not able to see that the VAR parameter was actually a TEMP table record. Damn.

Anyway, glad that I found this solution! Many Thanks!

1 Like