---
id: change/bcapps/13572
type: change
title: "#13572 Fix cloud migration company delete removing the wrong hybrid company"
summary: Cloud migration company deletion now removes the correct hybrid company and intelligent cloud status records instead of potentially deleting records for unrelated companies. The webhook subscription is moved to the first remaining company when the subscribed company is deleted.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit hybrid cloud management
system: administration
review:
  state: reviewed
  by: opus
  at: "2026-11-11T00:57:29.606Z"
  flags: []
generated:
  at: "2026-11-29T00:16:19.301Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: cc9a13111aa74f28b62873155cea3e7580f62fe9
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13572
    title: "microsoft/BCApps#13572: Fix cloud migration company delete removing the wrong hybrid company"
    date: "2026-11-10"
    commit: cc9a13111aa74f28b62873155cea3e7580f62fe9
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/4001
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/administration/migration-table-mapping
      title: Define Cloud Migration Table Mappings in Business Central
      label: possibly related
      why: touches Codeunit 4001 "Hybrid Cloud Management"
      by: code
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/administration/migration-setup
      title: Run Business Central Cloud Migration Setup
      label: possibly related
      why: Cloud Migration Setup configures components and company selection for data migration.
      by: model
number: 13572
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13572
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-10T17:31:19Z"
author: darjoo
author_type: User
community_contribution: false
labels:
  - "AL: Apps (W1)"
  - "Team: Integrations"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 2
  additions: 201
  deletions: 22
  al: 1
apps:
  - HybridBaseDeployment
objects_touched:
  - key: codeunit/4001
    page: codeunit/4001
    type: codeunit
    id: 4001
    name: Hybrid Cloud Management
    app: HybridBaseDeployment
    status: modified
objects_unjoined: []
obsoletions: []
backports:
  - number: 13896
    base: releases/29.x
    url: https://github.com/microsoft/BCApps/pull/13896
fixes_issues: []
work_items:
  - 657775
systems:
  - administration
quote: null
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13572 Fix cloud migration company delete removing the wrong hybrid company

> Cloud migration company deletion now removes the correct hybrid company and intelligent cloud status records instead of potentially deleting records for unrelated companies. The webhook subscription is moved to the first remaining company when the subscribed company is deleted.

[Pull request](https://github.com/microsoft/BCApps/pull/13572) · merged into `main` (BC30) on 2026-11-10 by darjoo · 2 files (+201 -22), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- HandleCompanyDelete now uses the deleted company (Rec) instead of a local Company variable to identify which records to remove
- Webhook handling refactored into separate methods IsCompanyWebhookCompany and MoveWebhookSubscription
- Webhook moves to first remaining company to keep cloud migration subscriptions functional
- Fixes issue where deleting the company holding webhook subscription caused deletion of wrong hybrid company records
- Tests added for company deletion and webhook transfer scenarios
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 4001 "Hybrid Cloud Management"](../../objects/codeunit/4001.md), HybridBaseDeployment: modified

## Also merged into

- [#13896](https://github.com/microsoft/BCApps/pull/13896) into `releases/29.x` on 2026-11-10

## Context

- Work items: AB#657775
- Labels: AL: Apps (W1), Team: Integrations
- Systems: administration

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Define Cloud Migration Table Mappings in Business Central](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/administration/migration-table-mapping) — possibly related: touches Codeunit 4001 "Hybrid Cloud Management"
- [Run Business Central Cloud Migration Setup](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/administration/migration-setup) — possibly related: Cloud Migration Setup configures components and company selection for data migration. (model-linked)

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
