ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Bug]: [Page][8082][Sales Service Commitments] Error opening page – “Document No. must have a value”

Open MortegaITB opened this issue 9 months ago • 0 comments

Describe the issue

When opening page 8082 "Sales Service Commitments" from the search bar, the page fails to open and throws an error. The error seems related to a missing Document No. in a Sales Subscription Line record.

Expected behavior

The page should open normally, displaying the sales service commitments without requiring any manual data in the subscription lines.

Steps to reproduce

Open Business Central.

  1. Use the search bar to navigate to Sales Service Commitments (Page 8082).
  2. Observe that the page fails to open and throws an error.

Additional context

The details of the error are as follows:

If requesting support, please provide the following details to help troubleshooting:

Error message: Document No. must have a value in Sales Subscription Line: Line No.=0. It cannot be zero or empty.

AL call stack: "Sales Subscription Line"(Table 8068).GetSalesHeader line 4 - Subscription Billing by Microsoft version 27.1.41698.41776 "Sales Subscription Line"(Table 8068).GetCurrency line 4 - Subscription Billing by Microsoft version 27.1.41698.41776

I believe the error occurs because the page is not yet fully initialized in the registry. When the AutoFormatExpression of field "Calculation Base Amount" executes, it calls GetCurrency(), which in turn calls GetSalesHeader(). Inside GetSalesHeader(), TestField("Document No.") is executed on the Sales Subscription Line, but the field is empty or zero, causing the error.

Relevant AL code snippet:

field(15; "Calculation Base Amount"; Decimal) { Caption = 'Calculation Base Amount'; MinValue = 0; BlankZero = true; AutoFormatType = 1; AutoFormatExpression = GetCurrency();

        trigger OnValidate()
        begin
            TestIfSalesOrderIsReleased();
            CalculatePrice();
        end;
    }
local procedure GetCurrency(): Code[10]
var
    SalesHeader: Record "Sales Header";
begin
    GetSalesHeader(SalesHeader);
    exit(SalesHeader."Currency Code");
end;
local procedure GetSalesHeader(var OutSalesHeader: Record "Sales Header")
var
    SalesHeader: Record "Sales Header";
begin
    TestField("Document No.");
    if ("Document Type" <> SalesHeader."Document Type") or ("Document No." <> SalesHeader."No.") then
        if SalesHeader.Get("Document Type", "Document No.") then
            if SalesHeader."Currency Code" = '' then
                Currency.InitRoundingPrecision()
            else begin
                SalesHeader.TestField("Currency Factor");
                Currency.Get(SalesHeader."Currency Code");
                Currency.TestField("Unit-Amount Rounding Precision");
                Currency.TestField("Amount Rounding Precision");
            end
        else
            Clear(SalesHeader);

    OutSalesHeader := SalesHeader;
end;

I will provide a fix for a bug

  • [ ] I will provide a fix for a bug

MortegaITB avatar Feb 11 '26 09:02 MortegaITB