mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-07 15:46:55 +01:00
knowledge(appsource): add AL validation guidance
This commit is contained in:
parent
293f9b13e7
commit
e9f870a0f8
22 changed files with 374 additions and 3 deletions
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
bc-version: [all]
|
||||
domain: appsource
|
||||
keywords: [onbeforecompanyopen, onaftercompanyopen, company-open, event-subscriber, login]
|
||||
technologies: [al]
|
||||
countries: [w1]
|
||||
application-area: [all]
|
||||
---
|
||||
|
||||
# Do not subscribe to company-open events
|
||||
|
||||
## Description
|
||||
|
||||
AppSource extensions must not subscribe to `OnBeforeCompanyOpen` or `OnAfterCompanyOpen`. These events run on the sign-in path, where an error can prevent access and even small amounts of work affect every company open. Move initialization to installation, upgrade, new-company initialization, or the first use of the feature instead.
|
||||
|
||||
## Best Practice
|
||||
|
||||
Initialize app data from install or upgrade code when its lifecycle belongs there. For work that can wait, perform an idempotent check when the feature is first used or schedule background work. Use `OnCompanyInitialize` only for data that must be created for a new company.
|
||||
|
||||
See sample: `do-not-subscribe-to-company-open-events.good.al`.
|
||||
|
||||
## Anti Pattern
|
||||
|
||||
An event subscriber bound to `OnBeforeCompanyOpen` or `OnAfterCompanyOpen`, even when its current body appears lightweight. Detection signal: either company-open event name in an `EventSubscriber` attribute.
|
||||
|
||||
See sample: `do-not-subscribe-to-company-open-events.bad.al`.
|
||||
|
||||
## See also
|
||||
|
||||
`community/knowledge/performance/oncompanyopen-subscribers-must-not-do-io.md` covers I/O and other expensive work on adjacent session-open events.
|
||||
Loading…
Add table
Add a link
Reference in a new issue