Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Report for Multiple Tables

Posted on by 4
I am getting this errors:
 
The property value '/Customer No./ = field(/No./)' on property 'DataItemLink' is not valid.
The property value '/Cust. Ledger Entry No./ = field(/Entry No./), /Customer No./ = field(/Customer No./)' on property 'DataItemLink' is not valid.
The property value '/Sell-to Customer No./ = field(/No./)' on property 'DataItemLink' is not valid.
 
The code is:
 
I will appreciate the help:
report 50129 /Report for multiple tables/
{
    //Make the report serachable fro Tell me
    UsageCategory = Administration;
    ApplicationArea = All;
    //Use RDL layout
    DefaultLayout = RDLC;
    //Specify the name of the file that the report will use
    RDLCLayout = 'MyRDLReport.rdl';
 
    dataset
    {
        dataitem(Customer; Customer)
        {
            //Sort table view based on the No. field
            DataItemTableView = Sorting(/No./);
            //Include the No. field in the filter tab
            RequestFilterFields = /No./;
            //print data only if at least one of the CustLedgerEntry and sales header items generates output
            PrintOnlyIfDetail = true;
 
            column(No_Customer; /No./)
            {
                //Include the caption of No. field
                IncludeCaption = true;
            }
 
            column(Name_Customer; Name)
            {
                //Include the caption of No. field
                IncludeCaption = true;
            }
 
            column(Phone_Customer; /Phone No./)
            {
                //Include the caption of No. field
                IncludeCaption = true;
            }
 
            column(Address_Customer; Address)
            {
                //Include the caption of No. field
                IncludeCaption = true;
            }
 
            column(EMail_Customer; /E-Mail/)
            {
                //Include the caption of No. field
                IncludeCaption = true;
            }
 
        }
 
        dataitem(CustLedger; /Cust. Ledger Entry/)
        {
 
            DataItemTableView = sorting(/Entry no./);
            // Set a filter on the child data item, **CustLedgerEntry** to select only the records where the
            // value of `Customer./No./` field and the `/Customer Ledger Entry/./Customer No./` field matches.
            DataItemLink = /Customer No./ = field(/No./);




 
            column(EntryNo_CustLedgerEntry; /Entry No./)
            {
                IncludeCaption = true;
 
            }
            column(CustomerNo_CustLedgerEntry; /Customer No./)
            {
                IncludeCaption = true;
 
            }
            column(PostingDate_CustLedgerEntry; /Posting Date/)
            {
                IncludeCaption = true;
 
            }
            column(DocumentType_CustLedgerEntry; /Document Type/)
            {
                IncludeCaption = true;
 
            }
 
            column(DocumentNo_CustLedgerEntry; /Document No./)
            {
                IncludeCaption = true;
 
            }
 
            column(Description_CustLedgerEntry; Description)
            {
                IncludeCaption = true;
 
            }
 
            column(CurrencyCode_CustLedgerEntry; /Currency Code/)
            {
                IncludeCaption = true;
 
            }
 
            column(Amount_CustLedgerEntry; Amount)
            {
                IncludeCaption = true;
 
            }
 
            column(OriginalAmtLCY_CustLedgerEntry; /Original Amt. (LCY)/)
            {
                IncludeCaption = true;
 
            }
 
            column(RemainingAmtLCY_CustLedgEntry; /Remaining Amt. (LCY)/)
            {
                IncludeCaption = true;
 
            }
 
        }
 
        dataitem(DetCustLedger; /Detailed Cust. Ledg. Entry/)
        {
 
            DataItemTableView = sorting(/entry no./);
            DataItemLink = /Cust. Ledger Entry No./ = field(/Entry No./), /Customer No./ = field(/Customer No./);
 
            column(EntryNo_DetailedCustLedgEntry; /Entry No./)
            {
                IncludeCaption = true;
 
            }
 
            column(EntryType_DetailedCustLedgEntry; /Entry Type/)
            {
                IncludeCaption = true;
 
            }
 
            column(PostingDate_DetailedCustLedgEntry; /Posting Date/)
            {
                IncludeCaption = true;
 
            }
 
            column(DocumentType_DetailedCustLedgEntry; /Document Type/)
            {
                IncludeCaption = true;
 
            }
 
            column(DocumentNo_DetailedCustLedgEntry; /Document No./)
            {
                IncludeCaption = true;
 
            }
 
            column(AmountLCY_DetailedCustLedgEntry; /Amount (LCY)/)
            {
                IncludeCaption = true;
 
            }
 
            column(TransactionNo_DetailedCustLedgEntry; /Transaction No./)
            {
                IncludeCaption = true;
 
            }
 
            column(JournalBatchName_DetailedCustLedgEntry; /Journal Batch Name/)
            {
                IncludeCaption = true;
 
            }
 
            column(DebitAmountLCY_DetailedCustLedgEntry; /Debit Amount (LCY)/)
            {
                IncludeCaption = true;
 
            }
 
            column(CreditAmountLCY_DetailedCustLedgEntry; /Credit Amount (LCY)/)
            {
                IncludeCaption = true;
 
            }
 
        }
 
        dataitem(SalesHeader; /Sales Header/)
        {
            DataItemTableView = sorting(/Document Type/, /No./);
            DataItemLink = /Sell-to Customer No./ = field(/No./);
 
            column(DocumentType_SalesHeader; /Document Type/)
            {
                IncludeCaption = true;
 
            }
 
            column(No_SalesHeader; /No./)
            {
                IncludeCaption = true;
 
            }
 
            column(PostingDate_SalesHeader; /Posting Date/)
            {
                IncludeCaption = true;
 
            }
 
            column(PricesIncludingVAT_SalesHeader; /Prices Including VAT/)
            {
                IncludeCaption = true;
 
            }
 
            column(Amount_SalesHeader; Amount)
            {
                IncludeCaption = true;
 
            }
        }
        //These labels will be used later as captions in the report layout.  
    }
    labels
    {
        Sales_Document_Caption = 'Sales Documents';
        Total_Caption = 'Total';
 
    }




 
}
Categories:
  • Verified answer
    Steven Renders Profile Picture
    Steven Renders 5,051 Super User 2024 Season 1 on at
    Report for Multiple Tables
    Your data items are not linked, they are after one another, so you are doing a union instead of a join.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    Report for Multiple Tables
    Hi, you can refer to the following standard examples.
     
    report 113 "Customer/Item Sales":
    namespace Microsoft.Sales.Reports;
    
    using Microsoft.Inventory.Item;
    using Microsoft.Inventory.Ledger;
    using Microsoft.Sales.Customer;
    using Microsoft.Utilities;
    using System.Utilities;
    
    report 113 "Customer/Item Sales"
    {
        DefaultLayout = RDLC;
        RDLCLayout = './Sales/Reports/CustomerItemSales.rdlc';
        ApplicationArea = Basic, Suite;
        Caption = 'Customer/Item Sales';
        PreviewMode = PrintLayout;
        UsageCategory = ReportsAndAnalysis;
        DataAccessIntent = ReadOnly;
    
        dataset
        {
            dataitem(Customer; Customer)
            {
                PrintOnlyIfDetail = true;
                RequestFilterFields = "No.", "Search Name", "Customer Posting Group";
                column(STRSUBSTNO_Text000_PeriodText_; StrSubstNo(PeriodTxt, PeriodText))
                {
                }
                column(COMPANYNAME; COMPANYPROPERTY.DisplayName())
                {
                }
                column(PrintOnlyOnePerPage; PrintOnlyOnePerPageReq)
                {
                }
                column(Customer_TABLECAPTION__________CustFilter; TableCaption + ': ' + CustFilter)
                {
                }
                column(CustFilter; CustFilter)
                {
                }
                column(Value_Entry__TABLECAPTION__________ItemLedgEntryFilter; "Value Entry".TableCaption + ': ' + ValueEntryFilter)
                {
                }
                column(ItemLedgEntryFilter; ValueEntryFilter)
                {
                }
                column(Customer__No__; "No.")
                {
                }
                column(Customer_Name; Name)
                {
                }
                column(Customer__Phone_No__; "Phone No.")
                {
                }
                column(ValueEntryBuffer__Sales_Amount__Actual__; TempValueEntryBuffer."Sales Amount (Actual)")
                {
                }
                column(ValueEntryBuffer__Discount_Amount_; -TempValueEntryBuffer."Discount Amount")
                {
                }
                column(Profit; Profit)
                {
                    AutoFormatType = 1;
                }
                column(ProfitPct; ProfitPct)
                {
                    DecimalPlaces = 1 : 1;
                }
                column(Customer_Item_SalesCaption; Customer_Item_SalesCaptionLbl)
                {
                }
                column(CurrReport_PAGENOCaption; CurrReport_PAGENOCaptionLbl)
                {
                }
                column(All_amounts_are_in_LCYCaption; All_amounts_are_in_LCYCaptionLbl)
                {
                }
                column(ValueEntryBuffer__Item_No__Caption; ValueEntryBuffer__Item_No__CaptionLbl)
                {
                }
                column(Item_DescriptionCaption; Item_DescriptionCaptionLbl)
                {
                }
                column(ValueEntryBuffer__Invoiced_Quantity_Caption; ValueEntryBuffer__Invoiced_Quantity_CaptionLbl)
                {
                }
                column(Item__Base_Unit_of_Measure_Caption; Item__Base_Unit_of_Measure_CaptionLbl)
                {
                }
                column(ValueEntryBuffer__Sales_Amount__Actual___Control44Caption; ValueEntryBuffer__Sales_Amount__Actual___Control44CaptionLbl)
                {
                }
                column(ValueEntryBuffer__Discount_Amount__Control45Caption; ValueEntryBuffer__Discount_Amount__Control45CaptionLbl)
                {
                }
                column(Profit_Control46Caption; Profit_Control46CaptionLbl)
                {
                }
                column(ProfitPct_Control47Caption; ProfitPct_Control47CaptionLbl)
                {
                }
                column(Customer__Phone_No__Caption; FieldCaption("Phone No."))
                {
                }
                column(TotalCaption; TotalCaptionLbl)
                {
                }
                dataitem("Value Entry"; "Value Entry")
                {
                    DataItemLink = "Source No." = field("No."), "Posting Date" = field("Date Filter"), "Global Dimension 1 Code" = field("Global Dimension 1 Filter"), "Global Dimension 2 Code" = field("Global Dimension 2 Filter");
                    DataItemTableView = sorting("Source Type", "Source No.", "Item No.", "Variant Code", "Posting Date") where("Source Type" = const(Customer), "Item Charge No." = const(''), "Expected Cost" = const(false), Adjustment = const(false));
                    RequestFilterFields = "Item No.", "Posting Date";
    
                    trigger OnAfterGetRecord()
                    var
                        ValueEntry: Record "Value Entry";
                        EntryInBufferExists: Boolean;
                    begin
                        TempValueEntryBuffer.Init();
                        TempValueEntryBuffer.SetRange("Item No.", "Item No.");
                        EntryInBufferExists := TempValueEntryBuffer.FindFirst();
    
                        if not EntryInBufferExists then
                            TempValueEntryBuffer."Entry No." := "Item Ledger Entry No.";
                        TempValueEntryBuffer."Item No." := "Item No.";
                        TempValueEntryBuffer."Invoiced Quantity" += "Invoiced Quantity";
                        TempValueEntryBuffer."Sales Amount (Actual)" += "Sales Amount (Actual)";
                        TempValueEntryBuffer."Cost Amount (Actual)" += "Cost Amount (Actual)";
                        TempValueEntryBuffer."Cost Amount (Non-Invtbl.)" += "Cost Amount (Non-Invtbl.)";
                        TempValueEntryBuffer."Discount Amount" += "Discount Amount";
    
                        TempItemLedgerEntry.SetRange("Entry No.", "Item Ledger Entry No.");
                        if TempItemLedgerEntry.IsEmpty() then begin
                            TempItemLedgerEntry."Entry No." := "Item Ledger Entry No.";
                            TempItemLedgerEntry.Insert();
    
                            // Add item charges regardless of their posting date
                            ValueEntry.SetRange("Item Ledger Entry No.", "Item Ledger Entry No.");
                            ValueEntry.SetFilter("Item Charge No.", '<>%1', '');
                            ValueEntry.CalcSums("Sales Amount (Actual)", "Cost Amount (Actual)", "Cost Amount (Non-Invtbl.)", "Discount Amount");
    
                            TempValueEntryBuffer."Sales Amount (Actual)" += ValueEntry."Sales Amount (Actual)";
                            TempValueEntryBuffer."Cost Amount (Actual)" += ValueEntry."Cost Amount (Actual)";
                            TempValueEntryBuffer."Cost Amount (Non-Invtbl.)" += ValueEntry."Cost Amount (Non-Invtbl.)";
                            TempValueEntryBuffer."Discount Amount" += ValueEntry."Discount Amount";
    
                            // Add cost adjustments regardless of their posting date
                            ValueEntry.SetRange("Item Charge No.", '');
                            ValueEntry.SetRange(Adjustment, true);
                            ValueEntry.CalcSums("Cost Amount (Actual)");
                            TempValueEntryBuffer."Cost Amount (Actual)" += ValueEntry."Cost Amount (Actual)";
                        end;
    
                        OnAfterGetValueEntryOnBeforeTempValueEntryBufferInsertModify("Value Entry", TempValueEntryBuffer);
    
                        if EntryInBufferExists then
                            TempValueEntryBuffer.Modify()
                        else
                            TempValueEntryBuffer.Insert();
                    end;
    
                    trigger OnPreDataItem()
                    begin
                        TempValueEntryBuffer.Reset();
                        TempValueEntryBuffer.DeleteAll();
                    end;
                }
                dataitem("Integer"; "Integer")
                {
                    DataItemTableView = sorting(Number);
                    column(ValueEntryBuffer__Item_No__; TempValueEntryBuffer."Item No.")
                    {
                    }
                    column(Item_Description; Item.Description)
                    {
                    }
                    column(ValueEntryBuffer__Invoiced_Quantity_; -TempValueEntryBuffer."Invoiced Quantity")
                    {
                        DecimalPlaces = 0 : 5;
                    }
                    column(ValueEntryBuffer__Sales_Amount__Actual___Control44; TempValueEntryBuffer."Sales Amount (Actual)")
                    {
                        AutoFormatType = 1;
                    }
                    column(ValueEntryBuffer__Discount_Amount__Control45; -TempValueEntryBuffer."Discount Amount")
                    {
                        AutoFormatType = 1;
                    }
                    column(Profit_Control46; Profit)
                    {
                        AutoFormatType = 1;
                    }
                    column(ProfitPct_Control47; ProfitPct)
                    {
                        DecimalPlaces = 1 : 1;
                    }
                    column(Item__Base_Unit_of_Measure_; Item."Base Unit of Measure")
                    {
                    }
    
                    trigger OnAfterGetRecord()
                    begin
                        if Number = 1 then
                            TempValueEntryBuffer.Find('-')
                        else
                            TempValueEntryBuffer.Next();
    
                        Profit :=
                          TempValueEntryBuffer."Sales Amount (Actual)" +
                          TempValueEntryBuffer."Cost Amount (Actual)" +
                          TempValueEntryBuffer."Cost Amount (Non-Invtbl.)";
    
                        if Item.Get(TempValueEntryBuffer."Item No.") then;
                    end;
    
                    trigger OnPreDataItem()
                    begin
                        TempValueEntryBuffer.Reset();
                        SetRange(Number, 1, TempValueEntryBuffer.Count);
                        Clear(Profit);
                    end;
                }
    
                trigger OnPreDataItem()
                begin
                    Clear(Profit);
                end;
            }
        }
    
        requestpage
        {
            SaveValues = true;
    
            layout
            {
                area(content)
                {
                    group(Options)
                    {
                        Caption = 'Options';
                        field(PrintOnlyOnePerPage; PrintOnlyOnePerPageReq)
                        {
                            ApplicationArea = Basic, Suite;
                            Caption = 'New Page per Customer';
                            ToolTip = 'Specifies if each customer''s information is printed on a new page if you have chosen two or more customers to be included in the report.';
                        }
                    }
                }
            }
    
            actions
            {
            }
        }
    
        labels
        {
        }
    
        trigger OnPostReport()
        begin
            if Customer.IsEmpty() and GuiAllowed() then
                Error(EmptyReportDatasetTxt);
        end;
    
        trigger OnPreReport()
        var
            FormatDocument: Codeunit "Format Document";
        begin
            CustFilter := FormatDocument.GetRecordFiltersWithCaptions(Customer);
            ValueEntryFilter := "Value Entry".GetFilters();
            PeriodText := "Value Entry".GetFilter("Posting Date");
        end;
    
        var
            TempItemLedgerEntry: Record "Item Ledger Entry" temporary;
            CustFilter: Text;
            ValueEntryFilter: Text;
            PeriodText: Text;
            PrintOnlyOnePerPageReq: Boolean;
            Profit: Decimal;
            ProfitPct: Decimal;
    
            PeriodTxt: Label 'Period: %1', Comment = '%1 - period text';
            Customer_Item_SalesCaptionLbl: Label 'Customer/Item Sales';
            CurrReport_PAGENOCaptionLbl: Label 'Page';
            All_amounts_are_in_LCYCaptionLbl: Label 'All amounts are in LCY';
            ValueEntryBuffer__Item_No__CaptionLbl: Label 'Item No.';
            Item_DescriptionCaptionLbl: Label 'Description';
            ValueEntryBuffer__Invoiced_Quantity_CaptionLbl: Label 'Invoiced Quantity';
            Item__Base_Unit_of_Measure_CaptionLbl: Label 'Unit of Measure';
            ValueEntryBuffer__Sales_Amount__Actual___Control44CaptionLbl: Label 'Amount';
            ValueEntryBuffer__Discount_Amount__Control45CaptionLbl: Label 'Discount Amount';
            Profit_Control46CaptionLbl: Label 'Profit';
            ProfitPct_Control47CaptionLbl: Label 'Profit %';
            TotalCaptionLbl: Label 'Total';
            EmptyReportDatasetTxt: Label 'There is nothing to print for the selected filters.';
    
        protected var
            Item: Record Item;
            TempValueEntryBuffer: Record "Value Entry" temporary;
    
        procedure InitializeRequest(NewPagePerCustomer: Boolean)
        begin
            PrintOnlyOnePerPageReq := NewPagePerCustomer;
        end;
    
        [IntegrationEvent(false, false)]
        local procedure OnAfterGetValueEntryOnBeforeTempValueEntryBufferInsertModify(ValueEntry: Record "Value Entry"; var TempValueEntry: Record "Value Entry" temporary)
        begin
        end;
    }
    
    
    Hope this helps as well.
    Thanks.
    ZHU
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    Report for Multiple Tables
    You can find a sample repository on github here that should solve your linking issues
     
    I hope that helps you.
  • Suggested answer
    Report for Multiple Tables
    Can you please try this ?
     
     
    dataitem(CustLedger; "Cust. Ledger Entry")
    {
        DataItemTableView = sorting("Entry No.");
        // Corrected syntax for DataItemLink
        DataItemLink = "Customer No." = field("No.");
        // ... other columns and properties
    }
    dataitem(DetCustLedger; "Detailed Cust. Ledg. Entry")
    {
        DataItemTableView = sorting("Entry No.");
        // Corrected syntax for DataItemLink with multiple fields
        DataItemLink = "Cust. Ledger Entry No." = field("Entry No."), 
                       "Customer No." = field("Customer No.");
        // ... other columns and properties
    }
    dataitem(SalesHeader; "Sales Header")
    {
        DataItemTableView = sorting("Document Type", "No.");
        // Corrected syntax for DataItemLink
        DataItemLink = "Sell-to Customer No." = field("No.");
        // ... other columns and properties
    }
     
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    Kamal Khakhkhar 299 on at
    Report for Multiple Tables
    Hii There,
    As per your code you are not used dataset: dataitem is completed before its linked to eachother. so its not linked to eachother. for this you need to correct closing brackets and give this 3 property according to requirement.
     
    1.DataItemLinkReference
    2.DataItemLink
    3.DataItemTableView
     
    Thank You.
    kamal Khakhkhar

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans