ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Bug]: "Subscription & Recurring Billing" - codeunit 8074 "Document Change Management" - IsRecurringBillingDocument

Open bcarmo-dev opened this issue 2 years ago • 4 comments

Describe the issue

I think there is a bug in the new Subscription & Recurring Billing module. When I try to create a new document for a Customer from the Customer List or the Customer Card that has some recurring sales line setup with "Insert Rec Lines" = Automatic , once I click on a new field on the Document Page and the OnInsert trigger is executed I get an error saying that the record does not exist.

Expected behavior

I suspect that this piece of code on the codeunit 8074 "Document Change Management" is creating this issue because the Sales Header it's not inserted yet at that point.

   local procedure IsRecurringBillingDocument(RRef: RecordRef) RecurringBilling: Boolean
    var
        SalesHeader: Record "Sales Header";
        SalesLine: Record "Sales Line";
        PurchaseHeader: Record "Purchase Header";
        PurchaseLine: Record "Purchase Line";
        FRef: FieldRef;
    begin
        case RRef.Number of
            Database::"Purchase Header", Database::"Sales Header":
                begin
                    FRef := RRef.Field(8051);   //Recurring Billing in Header Tables //Contract No. in Line tables
                    RecurringBilling := FRef.Value;
                end;
            Database::"Purchase Line":
                begin
                    RRef.SetTable(PurchaseLine);
                    PurchaseHeader.Get(PurchaseLine."Document Type", PurchaseLine."Document No.");
                    RecurringBilling := PurchaseHeader."Recurring Billing";
                end;
            Database::"Sales Line":
                begin
                    RRef.SetTable(SalesLine);
                    // Issue start here
                    SalesHeader.Get(SalesLine."Document Type", SalesLine."Document No.");
                    // Issue ends here
                    RecurringBilling := SalesHeader."Recurring Billing";
                end;
        end;
    end;

I expect that a validation is performed to verify if the record already exists.

Steps to reproduce

Having some recurring sales line setup for a Customer. Image

If you try to create a Document for that Customer from the Customer List or the Customer Card Image

When you change the focus of the first field you get the following error: Image

When you look to the callstack, you get the following:

AL call stack: 
"Document Change Management"(CodeUnit 8074).IsRecurringBillingDocument line 23 - Subscription & Recurring Billing by Microsoft
"Document Change Management"(CodeUnit 8074).PreventChangeOnDocumentHeaderOrLine line 16 - Subscription & Recurring Billing by Microsoft
"Document Change Management"(CodeUnit 8074).PreventChangeSalesLineType line 4 - Subscription & Recurring Billing by Microsoft
"Standard Customer Sales Code"(Table 172).ApplyStdCodesToSalesLines line 40 - Base Application by Microsoft
"Standard Codes Mgt."(CodeUnit 170).CheckCreateSalesRecurringLines line 13 - Base Application by Microsoft
"Sales Header"(Table 36).OnInsert(Trigger) line 21 - Base Application by Microsoft

Additional context

No response

bcarmo-dev avatar Oct 14 '24 15:10 bcarmo-dev

@bnielse, could you triage this issue?

JesperSchulz avatar Nov 04 '24 14:11 JesperSchulz

@miljance, what do you say? Is this something we need to look at?

JesperSchulz avatar Jun 13 '25 07:06 JesperSchulz

This should have been fixed already:

Image

miljance avatar Jun 13 '25 09:06 miljance

se the comment from Miljance "This should have been fixed already"

AndersLarsenMicrosoft avatar Sep 04 '25 19:09 AndersLarsenMicrosoft