Writing the custom business logic (Codeunit)

Now, it's time to write the business logic code.

As a best practice (https://community.dynamics.com/nav/w/designpatterns), we don't want to have code inside tables or pages so here we create two Codeunit objects:

  • Customer Management Codeunit: Contains all the business logic related to managing the Customer and Customer Category
  • Free Gift Management Codeunit: Contains all the business logic related to managing the Free Gift process

To create these Codeunits, we create two new AL files in the Src\CustomerCategory\codeunit and Src\Gifts\codeunit folders with the names of Cod50100.CustomerManagement.al and Cod50101.FreeGiftManagement.al, respectively.

We use the tcodeunit snipper to create a new ...

Get Dynamics 365 Business Central Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.