New system events replace Codeunit 1 in Business Central October’18 release
When you start upgrading to Business Central on-premises, you’ll notice that Codeunit 1 ApplicationManagement is missing. Not to worry, this is not a ‘bug’, it is by design. We’re refactoring the application as part of our move to modern development and to enable extensions to subscribe to events that were formerly handled by functions in codeunit 1.
The old ApplicationManagement codeunit has been retired, and new ‘system’ codeunits have been introduced in the 2 billion range.
These special codeunits are created by C/SIDE when a database is created so you will always have them, compiled, and ready to go. These new system codeunits do not contain code, all they contain are event publishers. Business Central Server will now call these event publishers instead of calling the respective functions in Codeunit 1 ApplicationManagement directly.
We have added subscribers to these new business events in various places in the application code to ensure all the functionality still works as before, no functionality was removed. Most of the real business logic was already moved out of the ApplicationManagement codeunit so these subscribers were added where the business logic really resides. The integration events were also moved from Codeunit 1 to their respective new homes.
You can find a detailed mapping of where each function moved in the table at the end of this blog post, and of course it will be part of the docs for the release of Business Central October’18. The list will be in the upgrade docs, so stay tuned for the update of the developer and ITPro docs!
The new ‘system’ codeunits are special in more ways than one. You will not be able to customize them as you would other codeunits. You also should not directly subscribe to the events in these codeunits either. While technically possible as of now, we will block this in the future which would be a breaking change for you. Instead you should subscribe to one of the integration events which now reside next to the business logic. The reason for this is to ensure the correct ordering of events and to provide before/after events where appropriate.
Of course this is a big change in how the server interacts with the application and you will need to adjust your customizations and extensions to this new way of working. You can find help and more information on how to do technical upgrade in the developer and ITPro docs for Business Central October’18 release.
Which functions become which events?
The following table describes the mapping from codeunit 1 to the new events:
Codeunit 1 function name | New object type | New object ID | New object name | New function name |
CompanyOpen | Codeunit | 40 | LogInManagement | CompanyOpen |
GetSystemIndicator | Codeunit | 40 | LogInManagement | GetSystemIndicator |
CompanyClose | Codeunit | 40 | LogInManagement | CompanyClose |
FindPrinter | Codeunit | 44 | ReportManagement | GetPrinterName |
ApplicationVersion | Codeunit | 9015 | Application System Constants | ApplicationVersion |
CustomApplicationVersion | N/A | N/A | N/A | N/A |
ReleaseVersion | Codeunit | 9015 | Application System Constants | ReleaseVersion |
ApplicationBuild | Codeunit | 9015 | Application System Constants | ApplicationBuild |
CustomApplicationBuild | N/A | N/A | N/A | N/A |
ApplicationLanguage | Codeunit | 43 | LanguageManagement | ApplicationLanguage |
DefaultRoleCenter | Codeunit | 9170 | Conf./Personalization Mgt. | DefaultRoleCenterID |
MakeDateTimeText | Codeunit | 41 | TextManagement | MakeDateTimeText |
GetSeparateDateTime | Codeunit | 41 | TextManagement | GetSeparateDateTime |
MakeDateText | Codeunit | 41 | TextManagement | MakeDateText |
MakeTimeText | Codeunit | 41 | TextManagement | MakeTimeText |
MakeText | Codeunit | 41 | TextManagement | MakeText |
MakeDateTimeFilter | Codeunit | 41 | TextManagement | MakeDateTimeFilter |
MakeDateFilter | Codeunit | 41 | TextManagement | MakeDateFilter |
MakeTextFilter | Codeunit | 41 | TextManagement | MakeTextFilter |
MakeCodeFilter | Codeunit | 41 | TextManagement | MakeTextFilter |
MakeTimeFilter | Codeunit | 41 | TextManagement | MakeTimeFilter |
AutoFormatTranslate | Codeunit | 45 | AutoFormatManagement | AutoFormatTranslate |
ReadRounding | Codeunit | 45 | AutoFormatManagement | ReadRounding |
CaptionClassTranslate | Codeunit | 42 | CaptionManagement | CaptionClassTranslate |
GetCueStyle | Codeunit | 9701 | Cue Setup | GetCueStyle |
SetGlobalLanguage | Codeunit | 43 | LanguageManagement | SetGlobalLanguage |
ValidateApplicationlLanguage | Codeunit | 43 | LanguageManagement | ValidateApplicationLanguage |
LookupApplicationlLanguage | Codeunit | 43 | LanguageManagement | LookupApplicationLanguage |
GetGlobalTableTriggerMask | Codeunit | 49 | GlobalTriggerManagement | GetGlobalTableTriggerMask |
OnGlobalInsert | Codeunit | 49 | GlobalTriggerManagement | OnGlobalInsert |
OnGlobalModify | Codeunit | 49 | GlobalTriggerManagement | OnGlobalModify |
OnGlobalDelete | Codeunit | 49 | GlobalTriggerManagement | OnGlobalDelete |
OnGlobalRename | Codeunit | 49 | GlobalTriggerManagement | OnGlobalRename |
GetDatabaseTableTriggerSetup | Codeunit | 49 | GlobalTriggerManagement | GetDatabaseTableTriggerSetup |
OnDatabaseInsert | Codeunit | 49 | GlobalTriggerManagement | OnDatabaseInsert |
OnDatabaseModify | Codeunit | 49 | GlobalTriggerManagement | OnDatabaseModify |
OnDatabaseDelete | Codeunit | 49 | GlobalTriggerManagement | OnDatabaseDelete |
OnDatabaseRename | Codeunit | 49 | GlobalTriggerManagement | OnDatabaseRename |
OnDebuggerBreak | Codeunit | 9500 | Debugger Management | ProcessOnDebuggerBreak |
LaunchDebugger | Codeunit | 9500 | Debugger Management | OpenDebugger |
OpenSettings | Codeunit | 9170 | Conf./Personalization Mgt. | OpenSettings |
OpenContactMSSales | Codeunit | 50 | SaaS Log In Management | OpenContactMSSales |
InvokeExtensionInstallation | Codeunit | 2501 | ExtensionMarketplaceMgmt | InvokeExtensionInstallation |
CustomizeChart | Codeunit | 9180 | Generic Chart Mgt | CustomizeChart |
HasCustomLayout | Codeunit | 44 | ReportManagement | HasCustomLayout |
MergeDocument | Codeunit | 44 | ReportManagement | MergeDocument |
ReportGetCustomRdlc | Codeunit | 44 | ReportManagement | ReportGetCustomRdlc |
ReportScheduler | Codeunit | 44 | ReportManagement | ScheduleReport |
OnBeforeOpenSettings | Codeunit | 9170 | Conf./Personalization Mgt. | OnBeforeOpenSettings |
OnAfterGetApplicationVersion | Codeunit | 9015 | Application System Constants | OnAfterGetApplicationVersion |
OnBeforeCompanyOpen | Codeunit | 40 | LogInManagement | OnBeforeCompanyOpen |
OnAfterCompanyOpen | Codeunit | 40 | LogInManagement | OnAfterCompanyOpen |
OnRoleCenterOpen | Codeunit | 9170 | Conf./Personalization Mgt. | OnRoleCenterOpen |
OnBeforeCompanyClose | Codeunit | 40 | LogInManagement | OnBeforeCompanyClose |
OnAfterCompanyClose | Codeunit | 40 | LogInManagement | OnAfterCompanyClose |
OnAfterGetSystemIndicator | Table | 79 | Company Information | OnAfterGetSystemIndicator |
OnAfterFindPrinter | Codeunit | 44 | ReportManagement | OnAfterGetPrinterName |
OnAfterGetDefaultRoleCenter | Codeunit | 9170 | Conf./Personalization Mgt. | OnAfterGetDefaultRoleCenter |
OnAfterMakeDateText | N/A | N/A | N/A | N/A |
OnAfterMakeTimeText | N/A | N/A | N/A | N/A |
OnAfterMakeText | N/A | N/A | N/A | N/A |
OnAfterMakeDateTimeFilter | Codeunit | 41 | TextManagement | OnAfterMakeDateTimeFilter |
OnAfterMakeDateFilter | Codeunit | 41 | TextManagement | OnAfterMakeDateFilter |
OnAfterMakeTextFilter | Codeunit | 41 | TextManagement | OnAfterMakeTextFilter |
OnAfterMakeCodeFilter | N/A | N/A | N/A | N/A |
OnAfterMakeTimeFilter | Codeunit | 41 | TextManagement | OnAfterMakeTimeFilter |
OnAfterAutoFormatTranslate | Codeunit | 45 | AutoFormatManagement | OnAfterAutoFormatTranslate |
OnAfterCaptionClassTranslate | Codeunit | 42 | CaptionManagement | OnAfterCaptionClassTranslate |
OnAfterGetGlobalTableTriggerMask | Codeunit | 49 | GlobalTriggerManagement | OnAfterGetGlobalTableTriggerMask |
OnAfterOnGlobalInsert | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnGlobalInsert |
OnAfterOnGlobalModify | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnGlobalModify |
OnAfterOnGlobalDelete | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnGlobalDelete |
OnAfterOnGlobalRename | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnGlobalRename |
OnAfterGetDatabaseTableTriggerSetup | Codeunit | 49 | GlobalTriggerManagement | OnAfterGetDatabaseTableTriggerSetup |
OnAfterOnDatabaseInsert | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnDatabaseInsert |
OnAfterOnDatabaseModify | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnDatabaseModify |
OnAfterOnDatabaseDelete | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnDatabaseDelete |
OnAfterOnDatabaseRename | Codeunit | 49 | GlobalTriggerManagement | OnAfterOnDatabaseRename |
OnAfterHasCustomLayout | Codeunit | 44 | ReportManagement | OnAfterHasCustomLayout |
OnAfterReportGetCustomRdlc | Table | 9650 | Custom Report Layout | OnAfterReportGetCustomRdlc |
OnBeforeOnDatabaseInsert | Codeunit | 49 | GlobalTriggerManagement | OnBeforeOnDatabaseInsert |
OnBeforeOnDatabaseModify | Codeunit | 49 | GlobalTriggerManagement | OnBeforeOnDatabaseModify |
OnBeforeOnDatabaseDelete | Codeunit | 49 | GlobalTriggerManagement | OnBeforeOnDatabaseDelete |
OnBeforeOnDatabaseRename | Codeunit | 49 | GlobalTriggerManagement | OnBeforeOnDatabaseRename |
OnEditInExcel | Codeunit | 6710 | ODataUtility | OnEditInExcel |
OnInstallAppPerDatabase | N/A | N/A | N/A | N/A |
OnInstallAppPerCompany | N/A | N/A | N/A | N/A |
OnCheckPreconditionsPerDatabase | Codeunit | 9900 | Data Upgrade Mgt. | OnCheckPreconditionsPerDatabase |
OnCheckPreconditionsPerCompany | Codeunit | 9900 | Data Upgrade Mgt. | RaiseOnCheckPreconditionsPerCompany |
OnUpgradePerDatabase | Codeunit | 9900 | Data Upgrade Mgt. | OnUpgradePerDatabase |
OnUpgradePerCompany | Codeunit | 9900 | Data Upgrade Mgt. | OnUpgradePerCompany |
OnValidateUpgradePerDatabase | Codeunit | 9900 | Data Upgrade Mgt. | OnValidateUpgradePerDatabase |
OnValidateUpgradePerCompany | Codeunit | 9900 | Data Upgrade Mgt. | OnValidateUpgradePerCompany |
19. September 2018: The table has been updated with object names so the new functions are more easily found in the Business Central development environment.