How to Set Up a Manual Event Subscriber in Business Central

By Maria Ocampo | February 28, 2020

An event subscriber is an AL method that listens to a specific event and determines which action to take when that event is raised.

Sometimes you need to subscribe to an event, but you need to control when that method code must be run. This can be done using the EventSubscriberInstance property as Manual.

In this way, you can determine when to activate your event subscriber methods.

When using the manual event subscriber, you will need to bind and unbind the subscriber codeunit.

The codeunit instance binds to the same exact instance and events will be raised on this instance.

If you define your subscriber codeunit as a local variable, once it goes out of scope, all the bindings are removed and you will not need to unbind it.

Let’s explain it with a practical example:

Setting up a Manual Event Subscriber | Example

Say you were asked to use an additional vendor remittance address for the check instead of the standard address.

These new fields were added to the vendor table and the vendor card page.

Now, you need to subscribe to the correct event in order to use the additional remittance address instead of the standard one.

If you check the code, you realize that there is an event to which you can subscribe and successfully place your code.

Notice that the variable Handled will determine if the standard code is executed or not.

The issue here is that this same function is called from many other reports and functionalities and all of them will be affected by it. Since that’s not what you want, you’ll need to manually subscribe the instance, setting the property EventSubscriberInstace = Manual.

Now, in the customized Check code, you bind/unbind the codeunit at the correct moment.

Let’s check the results.

If the check configured is a standard one, the new code should not be executed.

When printing the check, the standard address is shown as expected.

If the customized check is configured, the new code must execute.

When printing the check, the additional remittance address is shown as expected.


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!