---
id: change/bcquality/210
type: change
title: "#210 knowledge(upgrade): upgrade code must not use ChangeCompany"
summary: 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.
tier: official
language: en
tags:
  - feature
  - main
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:02:43.571Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 488ce50775bb1d94611191d2db83de35f7490763
evidence:
  - kind: code
    url: https://github.com/microsoft/BCQuality/pull/210
    title: "microsoft/BCQuality#210: knowledge(upgrade): upgrade code must not use ChangeCompany"
    date: "2026-10-02"
    commit: 488ce50775bb1d94611191d2db83de35f7490763
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 210
repo: microsoft/BCQuality
source_id: bcquality-prs
url: https://github.com/microsoft/BCQuality/pull/210
kind: pr
base_branch: main
major: null
merged_at: "2026-10-02T09:35:12Z"
author: JesperSchulz
author_type: User
community_contribution: false
labels: []
change_class: code
change_kind: feature
behavior_change: false
breaking: false
files:
  count: 6
  additions: 186
  deletions: 8
  al: 5
apps: []
objects_touched: []
objects_unjoined:
  - path: microsoft/knowledge/events/changecompany-runs-triggers-in-the-calling-company.md
    status: modified
    reason: not-in-snapshot
  - path: microsoft/knowledge/upgrade/no-changecompany-in-upgrade.bad.al
    status: added
    reason: not-in-snapshot
  - path: microsoft/knowledge/upgrade/no-changecompany-in-upgrade.good.al
    status: added
    reason: not-in-snapshot
  - path: microsoft/knowledge/upgrade/no-changecompany-in-upgrade.md
    status: added
    reason: not-in-snapshot
  - path: microsoft/skills/review/al-upgrade-review.md
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 651092
systems:
  - development
quote: null
joined_against:
  major: null
  commit: null
---

# #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.

[Pull request](https://github.com/microsoft/BCQuality/pull/210) · 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? snapshot
- `microsoft/knowledge/upgrade/no-changecompany-in-upgrade.bad.al`: added, not in the BC? snapshot yet
- `microsoft/knowledge/upgrade/no-changecompany-in-upgrade.good.al`: added, not in the BC? snapshot yet
- `microsoft/knowledge/upgrade/no-changecompany-in-upgrade.md`: added, not in the BC? snapshot yet
- `microsoft/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).
