How it works...

An event is a specific point in your code which developers can hook into in order to affect functionality. This allows for your application to be customized without modifying the source code, just as you do with the base Business Central application. There are two types of events that you can define in your code:

  • Business: An event that carries a promise that it will not be changed. Defining business events within your application can be considered the same as defining its API, and as such, there are likely to be ramifications to making changes to its definition.
  • Integration: It is an event that acts just like business events do, but these events do not have the same promise of not changing.

Defining the event publisher is just the first step. Without raising the event in your code, it will never execute, and therefore, anything subscribed to it will never execute. You raise the event by simply placing a call to the event in your code.

Although events can be raised anywhere in the code, you should take care and think about where you raise them. Adding an event on every other line of code within a function will not provide a good experience for developers and is unlikely to provide for an easier upgrade story. Only put events in places where they are absolutely necessary and where it makes sense. It might be best to err on the side of caution and add fewer events to your application to start with. It's easy to add more events, but once they're published, it becomes more challenging to remove them in cases where customers or partners may have already started using them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.122.162