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

Community site session details

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

Better understanding of Event Subscribers, Integration Events and IsHandled flags

(0) ShareShare
ReportReport
Posted on by 351

Hi,

I'd like to have a better understanding of event subscribers, integration events and IsHandled flag. Let's say there is a procedure in a base codeunit that looks like:

local procedure Procedure1()

    var
        IsHandled: Boolean;
    begin
        IsHandled := false;
        FirstIntegrationEvent(IsHandled);
        if IsHandled then
            exit;

        code
        SecondIntegrationEvent();
    end;
In my own codeunit, I create an event subscriber to the FirstIntegrationEvent, where I modify the code section and set IsHandled to true so the base code doesn't get executed
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Codeunit", 'FirstIntegrationEvent', '', true, true)]
    local procedure "Codeunit1_FirstIntegrationEvent"
    (
        var IsHandled: Boolean
    )
begin
        baseCodeModified
        //SecondIntegrationEvent(var1); //This line is removed as I can't called the 2nd integration event from my event subscriber
        IsHandled := true;
end;
I'm assuming, since I'm using IsHandled, that the 2nd integration event will never be called, correct? I know I could add some code to handle it if I need to call that 2nd event trigger. But what if another app/extension is calling that 2nd integration event. That part of the code from that extension will just be ignored?
It makes no sense to me, what am I missing
I have the same question (0)
  • Suggested answer
    Greg Enns Profile Picture
    1,106 on at
    RE: Better understanding of Event Subscribers, Integration Events and IsHandled flags

    You are correct. If you set IsHandled = TRUE, then the SecondIntegrationEvent will not be called. This is the difficulty and danger of customization.

    Your options are:

    A. You are responsible for making sure everything that needs to happen happens in your EventSubscriber.

    B. Handle ALL code in your Subscriber procedure.

    C. Subscribe to a different IntegrationEvent

    As you said, option B is difficult because you don't know who/what else might be subscribed to the SecondIntegrationEvent.

    Option C is always worth exploring. Perhaps you can find an IntegrationEvent later in the process? You might have to "Undo" some of what was done after FirstIntegrationEvent but that can still be the better option at times. Keep in mind that you can ask Microsoft to add IntegrationEvents (aka. "Event Publisher") anywhere in the system. You can do that here: AL Event Requests

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Better understanding of Event Subscribers, Integration Events and IsHandled flags

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sumit Singh Profile Picture

Sumit Singh 3,070

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,682 Super User 2025 Season 2

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans