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

I want to solve AL0818 error

(4) ShareShare
ReportReport
Posted on by 21
Here are the details: I have an  extension that is published on Microsoft Store. I want to make it work for BC26(Business central 2025 Release Wave1). 
  1. Extension:

    2. I have following code:
tableextension 71188627 “Service Invoice Header NBR” extends “Service Invoice Header”
{
    Caption = ‘Service Invoice Header’, Comment = ‘ro-RO=Antet Factura Service’;
    fields
    {
        field(71188575; “Invoicer Code NBR”; Code[20])
        {
            Caption = ‘Invoicer Code’, Comment = ‘ro-RO=Cod Facturist’;
            TableRelation = Employee;
            DataClassification = CustomerContent;
        }
        field(71188576; “Registration No. NBR”; Text[20])
        {
            Caption = ‘Registration No.’, Comment = ‘ro-RO=Nr. Inregistrare’;
            DataClassification = CustomerContent;
        }
        field(71188577; “Commerce Trade No. NBR”; Text[20])
        {
            Caption = ‘Commerce Trade No.’, Comment = ‘ro-RO=Nr. Inregistrare Registrul Comertului’;
            DataClassification = CustomerContent;
        }
        field(71188578; “VAT Date NBR”; Date)
        {
            Caption = ‘VAT Date NBR’, Comment = ‘ro-RO=Data TVA NBR’;
            DataClassification = CustomerContent;
            ObsoleteReason = ‘Replaced with VAT Reporting Date’;
#if not CLEAN220
            ObsoleteState = Pending;
#else
            ObsoleteState = Removed;
#endif
        }
    }
    keys
    {
        key(Key1NBR; “Posting Date”)
        {
        }
    }
#if not CLOUD260
    [IntegrationEvent(false, false)]
#pragma warning disable AL0818
    local procedure OnBeforePrintRecords(var ServiceInvoiceHeader: Record “Service Invoice Header”; ShowRequestPage: Boolean; var IsHandled: Boolean)
#pragma warning restore AL0818
    begin
    end;
#endif
}


3.1 When I try to run tehnical validation on BC26: (Run-AlValidation  -apps ("C:\Temp\Certificates\NET BRINEL SA_Romanian Localization App for Dynamics Business Central_26.0.0.1.app", "C:\Temp\Certificates\NET BRINEL SA_Localizare_TA_26.0.0.1.app") -affixes "NBR" -countries "ro"  -ValidateVersion "26" -previousApps ("C:\Temp\Certificates\NET BRINEL SA_Romanian Localization App for Dynamics Business Central_25.0.0.4.app", "C:\Temp\Certificates\NET BRINEL SA_Localizare_TA_25.0.0.4.app")

I get this error:
src\src\TableExtensions\ServiceInvoiceHeader.TableExt.al(4,25): error AS0018: Procedure ‘OnBeforePrintRecords(var Record “Service Invoice Header”, Boolean, var Boolean)’ has been removed in ‘TableExtension Service Invoice Header NBR’. A procedure that belongs to the public API must not be removed as it will break dependent extensions calling this procedure. App generation failed with exit code 1


3.2 If I remove from the above code: #if not CLOUD260 and #endif , I get this compiling error:
d:\Repos\bc_localizare\src\TableExtensions\ServiceInvoiceHeader.TableExt.al(48,21): error AL0819: The Table ‘Service Invoice Header’ already defines an event called ‘OnBeforePrintRecords’ with the same parameter types in ‘Base Application by Microsoft (26.0.30643.32552)’.
I tried in the past using pragma #pragma warning restore AL0818, but now this warning is being transformed into an error as they say here:
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/diagnostics/diagnostic-al818
Compiler Warning (future error) AL0818 – Business Central
The {0} ‘{1}’ already defines an event called ‘{2}’ with the same parameter types in ‘{3}’.

My Question: How can I make my extension work on BC26, and publish it to MS Store, without a breaking change?


Best regards,

Mihai M.

 
I have the same question (0)
  • Suggested answer
    Holly Huffman Profile Picture
    6,530 Super User 2025 Season 2 on at
    Good morning, afternoon, or evening depending on your location!
     
    The AL0818 error occurs because your extension defines an event (OnBeforePrintRecords) that conflicts with an event already defined in the Base Application for Business Central 26 (BC26). This is a breaking change because the event in your extension duplicates the one in the base application. Here's how you can resolve this issue and make your extension compatible with BC26 without introducing breaking changes:
     
    Steps to Resolve AL0818 Error
    1. Remove the Conflicting Event:
      • Since the OnBeforePrintRecords event is now part of the Base Application, you should remove it from your extension to avoid duplication.
      • Update your code to rely on the base application's event instead of redefining it.
        // Remove this block from your extension
        #if not CLOUD260
        [IntegrationEvent(false, false)]
        local procedure OnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
        begin
        end;
        #endif
    2. Subscribe to the Base Application Event:
      • Instead of defining the event in your extension, subscribe to the OnBeforePrintRecords event provided by the base application.
      • Create a new event subscriber in your extension to handle the event.
        [EventSubscriber(ObjectType::Table, Database::"Service Invoice Header", 'OnBeforePrintRecords', true, true)]
        local procedure HandleOnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
        begin
            // Add your custom logic here
        end;
    3. Use Preprocessor Symbols for Backward Compatibility:
      • If your extension needs to support both BC25 and BC26, use preprocessor symbols to conditionally include or exclude code based on the version.
      • For example:
        #if BC25
        [IntegrationEvent(false, false)]
        local procedure OnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
        begin
            // Logic for BC25
        end;
        #endif

        #if BC26
        [EventSubscriber(ObjectType::Table, Database::"Service Invoice Header", 'OnBeforePrintRecords', true, true)]
        local procedure HandleOnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
        begin
            // Logic for BC26
        end;
        #endif
    4. Update Preprocessor Symbols in app.json:
      • Ensure that your app.json file includes the correct preprocessor symbols for BC26 compatibility.
      • Add CLOUD260 to the preprocessorSymbols array to conditionally compile code for BC26.
        "preprocessorSymbols": [
            "CLEAN190",
            "CLEAN200",
            "CLEAN220",
            "CLOUD230",
            "CLOUD240",
            "CLOUD250",
            "CLOUD260"
        ]
    5. Run AL Validation:
      • After making these changes, run the AL Validation Tool again to ensure your extension passes technical validation for BC26.
        Run-AlValidation -apps ("path_to_your_app") -ValidateVersion "26"
    6. Test Thoroughly:
      • Test your extension in both BC25 and BC26 environments to ensure backward compatibility and proper functionality.
    Key Considerations
    • Backward Compatibility: Use preprocessor symbols to maintain compatibility with previous versions of Business Central.
    • Avoid Breaking Changes: Always rely on base application events when they are available, instead of redefining them in your extension.
    • Documentation: Update your extension's documentation to reflect the changes and ensure users understand the new behavior.
     
    Hope this helps some!
  • Verified answer
    MM-21010727-0 Profile Picture
    21 on at
    Hi, Thanks for the answer.
     
    I found following solution(adding CLOUD270 and [Obsolete ):
     
    // Remove this block from your extension
    #if not CLOUD270
    Obsolete('Pending removal', '27.0')]
    [IntegrationEvent(false, false)]
    local procedure OnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
    begin
    end;
    #endif
     
    // Remove this block from your extension  This is not pobbile, beacuse it's a breaking change.
    #if not CLOUD260
    [IntegrationEvent(false, false)]
    local procedure OnBeforePrintRecords(var ServiceInvoiceHeader: Record "Service Invoice Header"; ShowRequestPage: Boolean; var IsHandled: Boolean)
    begin
    end;
    #endif
     
    The steps 2 and 3 are not needed because function has no code, it was added by mistake in a previous version.
     
    Now it works, and technical validation runs successfully.
     
    Many thanks for your reply again.
  • Raj Borad Profile Picture
    1,424 on at
     
    Please mark the answer as verified and close the question, so that everyone gets updated on the community.
     
    Thanks.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,275 Super User 2025 Season 2 on at

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 3,229

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans