CodeCop Info AA0235
When using 'OnInstallAppPerCompany' you should also add 'Company-Initialize'::'OnCompanyInitialize' event subscriber.
Description
When using trigger 'OnInstallAppPerCompany' in a codeunit with 'Subtype = Install' you should also add a 'Company-Initialize'::'OnCompanyInitialize' event subscriber to ensure that new companies also have the correct setup.
Reason for the rule
'OnInstallAppPerCompany' is only run on companies that exist when installing the extension. Many extensions were missing a 'OnCompanyInitialize' subscription, so companies that were created after the extension installation were missing setup that the extension should do. For example, insertion of records in some tables was done only for existing companies and not for new ones.
Bad code example
codeunit 1160 "AP Install"
{
Subtype = Install;
trigger OnInstallAppPerCompany()
begin
...
end;
}
Good code example
codeunit 1160 "AP Install"
{
Subtype = Install;
trigger OnInstallAppPerCompany()
begin
...
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Company - Initialize", 'OnCompanyInitialize', '', false, false)]
local procedure CompanyInitialize()
begin
...
end;
}
See Also
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示