[Event][Subscription Billing] Add extensibility event after inserting contract description lines in purchase billing documents · Issue #12771 · microsoft/BCApps · GitHub
Skip to content

[Event][Subscription Billing] Add extensibility event after inserting contract description lines in purchase billing documents #12771

Description

@clasalal

Why do you need this change?

We need to add additional contract-specific information immediately after the standard contract description lines in generated purchase invoices. While this scenario is fully supported in sales billing through the existing OnAfterInsertContractDescriptionSalesLines event, there is currently no supported extension point to achieve the same result in purchase billing.

Providing an equivalent event would align both subscription billing processes and ensure a consistent extensibility model across sales and purchasing.

The sales subscription billing process already exposes extensibility events before and after the standard contract description lines are inserted into generated sales documents. These events allow partners to add contract-specific information at the exact point where a new contract section begins within the document.

The purchase subscription billing process contains comparable functionality and inserts equivalent contract description lines, but no corresponding extensibility event is available. This prevents partners from implementing the same customizations and creates an unnecessary inconsistency between sales and purchase subscription billing extensibility.

We need to add additional contract-specific information immediately after the standard contract description lines in generated purchase invoices. While this scenario is fully supported in sales billing through the existing OnAfterInsertContractDescriptionSalesLines event, there is currently no supported extension point to achieve the same result in purchase billing.

Providing an equivalent event would align both subscription billing processes and ensure a consistent extensibility model across sales and purchasing.

Describe the request

The sales subscription billing process already provides extensibility events around the insertion of contract description lines (OnBeforeInsertContractDescriptionSalesLines and OnAfterInsertContractDescriptionSalesLines). However, the purchase subscription billing process does not provide equivalent extensibility points, creating an inconsistency between the sales and purchase subscription billing APIs.

We request an integration event to be raised after the standard contract description lines are inserted into generated purchase documents, allowing partners to extend the process in the same way currently supported for sales billing documents.

The purchase subscription billing process does not provide equivalent extensibility points when contract description lines are inserted into the generated purchase document.

As a result, partners cannot add contract-specific information immediately after the standard contract description lines, nor can they extend this part of the process in a consistent way across sales and purchase subscription billing.

We request an event equivalent to the existing sales event to be raised after the standard contract description lines are inserted into purchase documents.

For example:

[IntegrationEvent(false, false)]
local procedure OnAfterInsertContractDescriptionPurchaseLines(
    PurchaseHeader: Record "Purchase Header";
    BillingLine: Record "Billing Line";
    FirstContractDescriptionLineInserted: Boolean;
    VendorRecurringBillingGrouping: Enum "Vendor Rec. Billing Grouping")
begin
end;

Alternatively, Microsoft could expose both OnBefore... and OnAfter... events to provide the same extensibility model available in the sales billing process.

Business impact

Without this event, partners must rely on unsupported workarounds or modifications of the standard process to enrich generated purchase documents with contract-specific information.

Adding the event would:

Improve extensibility of the purchase subscription billing process.
Align purchase billing extensibility with the existing sales billing model.
Reduce customization effort and upgrade risks.
Enable partner solutions that require additional contract information in generated purchase invoices.

Provide an implementation (optional)

  • I will provide the implementation for this extensibility request

Activity

  1. added theissue type on Oct 13, 2026
  2. github-actions commented on Oct 13, 2026

    @github-actions
    Contributor

    ✅ Analysis complete - ready for further processing


    Implementation:

    Add matching purchase subscription billing integration events around InsertContractDescriptionPurchaseLines, including an OnAfterInsertContractDescriptionPurchaseLines event after the standard contract description lines are inserted, and an OnBeforeInsertContractDescriptionPurchaseLines event with IsHandled for parity with the sales extensibility model.

    Location in InsertContractDescriptionPurchaseLines procedure:

        local procedure InsertContractDescriptionPurchaseLines(BillingLine: Record "Billing Line")
        var
            ContractTypeDescription: Text;
            IsHandled: Boolean; // NEW
        begin
            IsHandled := false; // NEW
            OnBeforeInsertContractDescriptionPurchaseLines(PurchaseHeader, BillingLine, FirstContractDescriptionLineInserted, VendorRecurringBillingGrouping, IsHandled); // NEW
            if not IsHandled then begin // NEW
                TranslationHelper.SetGlobalLanguageByCode(PurchaseHeader."Language Code");
                if FirstContractDescriptionLineInserted then
                    InsertDescriptionPurchaseLine('', 0);
                InsertDescriptionPurchaseLine(StrSubstNo(ContractNoTxt, BillingLine."Subscription Contract No."), 0);
                ContractTypeDescription := GetContractTypeDescription(BillingLine."Subscription Contract No.", BillingLine.Partner, PurchaseHeader."Language Code");
                if ContractTypeDescription <> '' then
                    InsertDescriptionPurchaseLine(ContractTypeDescription, 0);
                if VendorRecurringBillingGrouping <> VendorRecurringBillingGrouping::Contract then
                    FirstContractDescriptionLineInserted := true;
                TranslationHelper.RestoreGlobalLanguage();
            end; // NEW
            OnAfterInsertContractDescriptionPurchaseLines(PurchaseHeader, BillingLine, FirstContractDescriptionLineInserted, VendorRecurringBillingGrouping); // NEW
        end;

    Event Publisher (add at the end of the codeunit with other events):

        [IntegrationEvent(false, false)]
        local procedure OnBeforeInsertContractDescriptionPurchaseLines(PurchaseHeader: Record "Purchase Header"; BillingLine: Record "Billing Line"; var FirstContractDescriptionLineInserted: Boolean; VendorRecurringBillingGrouping: Enum "Vendor Rec. Billing Grouping"; var IsHandled: Boolean)
        begin
        end;
    
        [IntegrationEvent(false, false)]
        local procedure OnAfterInsertContractDescriptionPurchaseLines(PurchaseHeader: Record "Purchase Header"; BillingLine: Record "Billing Line"; var FirstContractDescriptionLineInserted: Boolean; VendorRecurringBillingGrouping: Enum "Vendor Rec. Billing Grouping")
        begin
        end;

    File: CreateBillingDocuments.Codeunit.al

    Note

    Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

    Tip

    Is the triage result incorrect? Reply with /not-accurate and briefly explain what was wrong. Your feedback improves future responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions