SBX - Search With Button

SBX - Forum Post Title

Adding table extension fields to a report

Dynamics 365 Business Central Forum

Michael Scalamogna asked a question on 9 Aug 2018 3:28 PM

Question Status

Verified

Hi everyone. Has anyone added data from a table extension to a report and had success?

I've been looking through the forum and saw a couple of threads that talk about creating custom reports but none of them lay out the steps required to link a table extension to a report using al code.

We created a table extension on the sales invoice line and I am trying to add the two fields that we added to the sales invoice form. Here is the code that i've written so far. I'm used to doing things like this in SQL where I'd just need to add a join but AL seems a lot different... any help is appreciated. It's not letting me just add another data item like i did to add the sales invoice line table. 

report 50105 "Sales Invoice Test Report"
{
DefaultLayout = RDLC;
RDLCLayout = 'sales_inv_test.rdl';
dataset
{
dataitem("Sales Invoice Header";"Sales Invoice Header")
{
RequestFilterFields = "No.";
column(No_;"No.")
{
}
column(Sell_to_Customer_No_;"Sell-to Customer No.")
{
}
column(Document_Date;"Document Date")
{
}
column(Amount;Amount)
{
}
column(Remaining_Amount;"Remaining Amount")
{
}
dataitem("Sales Invoice Line";"Sales Invoice Line")
{
DataItemLinkReference = "Sales Invoice Header";
DataItemLink = "Document No." = field("No.");
column(Line_No_;"Line No.")
{
}
column(Description;Description)
{
}
column(Quantity;Quantity)
{
}
column(Unit_Price;"Unit Price")
{
}
// This is where I would expect to link the table extension
// dataitemlinkreference
// dataitemlink
}
}

}
Reply
Suggested Answer

Is this report in the same extension of your tableextension object or in another extension (app)?

If case 1: you should see the added field directly in Sales Invoice Line

If case 2: you need to add the extension containing your tableextension as dependency of the new extension where you have the report.

Reply
Michael Scalamogna responded on 10 Aug 2018 7:26 AM

Hey Stefano, thanks for the response. I'm not sure I understand. The table extension is on the sales invoice line table, and one of the dataitems in the report is the sales invoice line. Are you saying that the fields in the table extension should just be available? In VS Code, I get a message that says "the name Gross Quantity does not exist in the current context" when i try to add a column.

Reply
Verified Answer

Is the report you’re developing in the same extension project as your tableextension object? If so, fields are visible.

If it’s not in the same extension project but it a new one (new project in VS Code), then you need to add dependency in app.json.

Reply
Michael Scalamogna responded on 10 Aug 2018 1:16 PM

This worked, thank you! I knew it had to be something simple.

Reply
Verified Answer

Is the report you’re developing in the same extension project as your tableextension object? If so, fields are visible.

If it’s not in the same extension project but it a new one (new project in VS Code), then you need to add dependency in app.json.

Reply
Suggested Answer

Is this report in the same extension of your tableextension object or in another extension (app)?

If case 1: you should see the added field directly in Sales Invoice Line

If case 2: you need to add the extension containing your tableextension as dependency of the new extension where you have the report.

Reply

SBX - Two Col Forum

SBX - Migrated JS