#210 knowledge(upgrade): upgrade code must not use ChangeCompany
New quality rule and knowledge article prevent upgrade code from using ChangeCompany, which can cause data races, duplicate upgrades, and trigger misexecution in the calling company context.
- 6files
- 5AL files
- 0objects
Pull request · merged into main on 2026-10-02 by JesperSchulz · 6 files (+186 -8), 5 AL · feature · tier official · reviewed (checked by Opus)
What changed
- New upgrade article flags ChangeCompany in upgrade codeunits, helpers reachable from their triggers, and Feature Data Update implementations
- Per-company upgrade triggers already run in each company’s own session, so ChangeCompany can duplicate or race upgrades and write upgrade tags in the wrong company
- Best practice: per-company work in OnUpgradePerCompany with a per-company tag, PerDatabase only for non-per-company data, and scheduled per-company tasks instead of ChangeCompany
- al-upgrade-review skill gains ChangeCompany, Feature Data Update and UpdateData worklist tokens routing to the new article
- Reads are included on purpose; parameterless ChangeCompany() and runtime code are excluded; scope is w1, all versions and application areas
AL objects touched
microsoft/knowledge/events/changecompany-runs-triggers-in-the-calling-company.md: modified, not in the BC? snapshotmicrosoft/knowledge/upgrade/no-changecompany-in-upgrade.bad.al: added, not in the BC? snapshot yetmicrosoft/knowledge/upgrade/no-changecompany-in-upgrade.good.al: added, not in the BC? snapshot yetmicrosoft/knowledge/upgrade/no-changecompany-in-upgrade.md: added, not in the BC? snapshot yetmicrosoft/skills/review/al-upgrade-review.md: modified, not in the BC? snapshot
Context
- Work items: AB#651092
- Systems: development
Source: metadata of a merged pull request in microsoft/BCQuality (bcquality): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).