microsoft / microsoft/BCApps

Item table synchronization leaves orphaned Tenant Media records in the receiving company

Open
#11,566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

agent-not-processable Team: SCM
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Why do you need this change?

We use Business Central Master Data Management to synchronize Item records between companies, including the Picture field of table 27 "Item".

The initial synchronization works correctly and creates the Item and the associated media references in the receiving company. However, when the Item is synchronized again after modifying a non-media field, such as Description, Business Central creates a new Tenant Media record and updates the Tenant Media Set reference without deleting the previously created Tenant Media record in the receiving company.

As a result, repeated synchronizations can leave orphaned records in the system Tenant Media table. This causes unnecessary database growth and may lead to data consistency and storage issues over time.

We need the synchronization process to correctly preserve or update the media references and remove Tenant Media records that are no longer referenced. If this cannot be resolved within the standard synchronization process, we would like to identify a suitable solution to prevent orphaned records from accumulating in the receiving company.

Describe the request

The issue can be reproduced as follows:

  1. In the source company (in the example "J"), create an Item and upload an image to the Picture field.

  2. Configure Master Data Management synchronization with a second company (in the example "R") as the receiving company. Include table 27 "Item" and the Picture field in the synchronization mapping.

  3. Run the synchronization for the first time.

  4. Verify that the Item is created correctly in the receiving company and that the corresponding records and references are created in:

    • Table 27 "Item"
    • System table "Tenant Media Set"
    • System table "Tenant Media"
  5. In the source company, modify only the Item Description in order to trigger another synchronization. Do not modify or replace the Picture.

  6. Run the synchronization again.

After the second synchronization:

  • The Picture ID stored on the Item remains unchanged.
  • The Media ID referenced by Tenant Media Set in the receiving company changes.
  • A new Tenant Media record is created in the receiving company.
  • The previous Tenant Media record in the receiving company is not deleted, even though it is no longer referenced by Tenant Media Set.
  • The obsolete Tenant Media record therefore remains orphaned.

Expected result:

If recreating the media reference is required by the synchronization implementation, the previous Tenant Media record in the receiving company should be deleted after the Tenant Media Set record has been updated, provided that the media record is no longer referenced anywhere else.

Evidence:

  1. Item created in the source company
Image
  1. Tenant Media and Tenant Media Set after the initial synchronization
Image Image The receiving company initially references Media ID: {cebd5101-f0e5-4bc5-9e81-2b54042ecb34}
  1. Tenant Media records after the subsequent synchronization
Image

After the subsequent synchronization, two Tenant Media records exist in the receiving company:

  • Previous Media ID: {cebd5101-f0e5-4bc5-9e81-2b54042ecb34}
  • New Media ID: {a0b4ee75-882e-4ad8-b534-aeacd04773d1}
  1. Tenant Media Set after the subsequent synchronization
Image

The Tenant Media Set record now references the new Media ID:
{a0b4ee75-882e-4ad8-b534-aeacd04773d1}

The previous Tenant Media record is no longer referenced by this Tenant Media Set record but remains in the receiving company.

Provide an implementation (optional)
  • I will provide the implementation for this extensibility request

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files, tests, or entry points; start by locating the Master Data Management synchronization handling for Item Picture and Tenant Media records. Reproduce the two synchronization runs, then verify that an obsolete Tenant Media record is removed when it is no longer referenced anywhere else.

Written by the indexing model from the issue text.

Assessment

Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.