When you create an extension, you need to check some conditions for the installation to be successful, or you need to initiate some setup tables or pre-populate other tables. To do this, you need to create Install codeunit.
The extension's install logic must be written in a codeunit with the SubType property set to Install. This logic is triggered when the following is true:
- You're installing the extension for the first time.
- You have uninstalled the extension and then you're installing it again.
An Install codeunit supports the following system triggers:
- OnInstallAppPerCompany(): The code inside this trigger runs once for each company in the Dynamics 365 Business Central database.
- OnInstallAppPerDatabase() ...