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.

Related Posts

Recommended Reading:

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article

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!

X