web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Unable to link Sales Header Archive and Sales Line Archive

(0) ShareShare
ReportReport
Posted on by 29

Hi team, 

I am trying to create a new document print on an Archive sales order, trying to link with the sales order archive header, and  Line getting the below error. Pls guide how I can solve this issue 

pastedimage1666852556864v1.png

refer the code 

================================

report 60120 Salesorderarchive
{
Caption = 'SalesOrder Archive';
UsageCategory = ReportsAndAnalysis;
ApplicationArea = All;

dataset
{
dataitem("Sales H Archive"; "Sales Header Archive")
{
PrintOnlyIfDetail = true;
column(Hno; "Sales H Archive"."No.") { }
column(Hdate; "Sales H Archive"."Order Date") { }
column(Hcustomer; "Sales H Archive"."Sell-to Customer No.") { }
column(HCustname; "Sales H Archive"."Sell-to Customer Name") { }
column(HSPeron; "Sales H Archive"."Salesperson Code") { }
column(HDocType; "Sales H Archive"."Document Type") { }
column(HVersion_No; "Sales H Archive"."Version No.") { }

// column(Sales_Header_Archive_Document_Type; "Document Type")
// column(Sales_Header_Archive_No_; "No."){}


}
// Archive Line item // -- Start

dataitem("Sales Line Archive"; "Sales Line Archive") // "Sales Line Archive"; "Sales Line Archive"
{

DataItemLink = "Document Type" = FIELD("Document Type"), "Document No." = FIELD("No.");
DataItemLinkReference = "Sales Header Archive";
DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");

column(Alineno; "Sales L Archive"."No.") { }
column(ALinedocno; "Sales L Archive"."Document No.") { }
column(AlinedocType; "Sales L Archive"."Document Type") { }
column(Alinedesciption; "Sales L Archive".Description) { }
column(ALineUnitofMeasure; "Sales L Archive"."Unit of Measure") { }
column(Quantity_SalesLine; "Sales L Archive".Quantity) { }
column(ALineUnitPrice; "Sales L Archive"."Unit Price") { }
column(AlLineDiscountAmt; "Sales L Archive"."Line Discount Amount") { }
column(TotalAmount; TotalAmount) { }
column(ALineVATAmount; "Amount Including VAT" - Amount) { }
column(AlineAmount_SalesLine; "Sales L Archive".Amount) { }
column(AllineAmountIncludingVAT_SalesLine; "Sales L Archive"."Amount Including VAT") { }
column(CI; CI) { }

trigger OnAfterGetRecord()
begin

CI += 1;
TotalAmount := (("Sales L Archive"."Unit Price") * ("Sales L Archive".Quantity)) - "Sales L Archive"."Line Discount Amount";
TotalAmount += "Sales L Archive"."Amount Including VAT";
RepCheck.InitTextVariable;
RepCheck.FormatNoText(NoText, TotalAmount, "Sales H Archive"."Currency Code");
AmountInWords := NoText[1];
end;

trigger OnPreDataItem()
begin
TotalAmount := 0;
CI := 0;
end;

} // Sales Line End


}

requestpage
{
layout { }

actions { }

}

// rendering
// {
// layout(LayoutName)
// {
// Type = RDLC;
// LayoutFile = 'mylayout.rdl';
// }
// }

var
myInt: Integer;
AmountInWords: Text;
RepCheck: Report "Check";
TotalAmount: Decimal;
NoText: array[2] of Text;
CI: Integer;
}

I have the same question (0)
  • Verified answer
    DAnny3211 Profile Picture
    11,397 on at

    hi

    try setting the archive row properties like this

    DataItemLink = "Document No.=FIELD(No.),Doc. No. Occurrence=FIELD(Doc. No. Occurrence),Version No.=FIELD(Version No.);

    DataItemLinkReference = "Sales H Archive";

    DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");

    if my answer was helpful, please check it

    DAniele

  • Verified answer
    YUN ZHU Profile Picture
    95,597 Super User 2025 Season 2 on at

    Hi, It looks like there is something wrong with the structure and variable names.
    I modified it slightly, but haven't debugged it.

    report 50111 Salesorderarchive
    {
        Caption = 'SalesOrder Archive';
        UsageCategory = ReportsAndAnalysis;
        ApplicationArea = All;
    
        dataset
        {
            dataitem("Sales H Archive"; "Sales Header Archive")
            {
                PrintOnlyIfDetail = true;
                column(Hno; "Sales H Archive"."No.") { }
                column(Hdate; "Sales H Archive"."Order Date") { }
                column(Hcustomer; "Sales H Archive"."Sell-to Customer No.") { }
                column(HCustname; "Sales H Archive"."Sell-to Customer Name") { }
                column(HSPeron; "Sales H Archive"."Salesperson Code") { }
                column(HDocType; "Sales H Archive"."Document Type") { }
                column(HVersion_No; "Sales H Archive"."Version No.") { }
    
                // column(Sales_Header_Archive_Document_Type; "Document Type")
                // column(Sales_Header_Archive_No_; "No."){}
    
    
    
                // Archive Line item // -- Start
    
                dataitem("Sales L Archive"; "Sales Line Archive") // "Sales Line Archive"; "Sales Line Archive"
                {
    
                    DataItemLink = "Document Type" = FIELD("Document Type"), "Document No." = FIELD("No.");
                    DataItemLinkReference = "Sales H Archive";
                    DataItemTableView = SORTING("Document Type", "Document No.", "Line No.");
    
                    column(Alineno; "Sales L Archive"."No.") { }
                    column(ALinedocno; "Sales L Archive"."Document No.") { }
                    column(AlinedocType; "Sales L Archive"."Document Type") { }
                    column(Alinedesciption; "Sales L Archive".Description) { }
                    column(ALineUnitofMeasure; "Sales L Archive"."Unit of Measure") { }
                    column(Quantity_SalesLine; "Sales L Archive".Quantity) { }
                    column(ALineUnitPrice; "Sales L Archive"."Unit Price") { }
                    column(AlLineDiscountAmt; "Sales L Archive"."Line Discount Amount") { }
                    column(TotalAmount; TotalAmount) { }
                    column(ALineVATAmount; "Amount Including VAT" - Amount) { }
                    column(AlineAmount_SalesLine; "Sales L Archive".Amount) { }
                    column(AllineAmountIncludingVAT_SalesLine; "Sales L Archive"."Amount Including VAT") { }
                    column(CI; CI) { }
    
                    trigger OnAfterGetRecord()
                    begin
    
                        CI  = 1;
                        TotalAmount := (("Sales L Archive"."Unit Price") * ("Sales L Archive".Quantity)) - "Sales L Archive"."Line Discount Amount";
                        TotalAmount  = "Sales L Archive"."Amount Including VAT";
                        RepCheck.InitTextVariable;
                        RepCheck.FormatNoText(NoText, TotalAmount, "Sales H Archive"."Currency Code");
                        AmountInWords := NoText[1];
                    end;
    
                    trigger OnPreDataItem()
                    begin
                        TotalAmount := 0;
                        CI := 0;
                    end;
    
                } // Sales Line End
            }
    
    
        }
    
        requestpage
        {
            layout { }
    
            actions { }
    
        }
    
        // rendering
        // {
        // layout(LayoutName)
        // {
        // Type = RDLC;
        // LayoutFile = 'mylayout.rdl';
        // }
        // }
    
        var
            myInt: Integer;
            AmountInWords: Text;
            RepCheck: Report "Check";
            TotalAmount: Decimal;
            NoText: array[2] of Text;
            CI: Integer;
    }

    Hope this helps.

    Thanks.

    ZHU

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,917

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,161 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,025 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans