Skip to content

[Bug]: Eventrequest for Codeunit 7500 "Item Attribute Management" #8968

Description

@NicoBroenstrup

Describe the issue

Describe the issue

Codeunit 7500 "Item Attribute Management" exposes the public procedure UpdateItemVariantAttributeFromItem(ItemCode: Code[20]). This procedure loops over all variants of an item and calls the local overload UpdateItemVariantAttributeFromItem(ItemVariant, TempItemAttributeValue, ItemCode) to apply the item's attributes to each variant.

There is no integration event inside this loop, and the pre-variant overload is 'local'. As a result, an extension has no supported way to exclude individual variants from the update. The only workaround is to fully duplicate the standard attribute logic in a custom codeunit.

Expected behavior

Expected behavior

An extension should be able to skip the attribute update for a specific variant during the loop, without re-implementing the standard logic. A single 'OnBefore..' integration event with an 'IsHandled' parameter inside the loop would be sufficient.

Proposed event (add at the end of Codeunit 7500):

[IntegrationEvent(false, false)]
local procedure OnUpdateItemVariantAttributeFromItemOnBeforeLoopIteration(ItemVariant: Record "Item Variant"; var IsHandled: Boolean)
begin
end;

Raised inside the existing loop of UpdateItemVariantAttributeFromItem(ItemCode):

if ItemVariant.FindSet() then
    repeat
        IsHandled := false; 
        OnUpdateItemVariantAttributeFromItemOnBeforeLoopIteration(ItemVariant, IsHandled);
        if not IsHandled then
            UpdateItemVariantAttributeFromItem(ItemVariant, TempItemAttributeValue, ItemCode);
    until ItemVariant.Next() = 0;

Steps to reproduce

Steps to reproduce

  1. In an extension, create a table extension on "Item Variant" that distinguishes
    "leaf" variants from "intermediate/parent" variants (e.g. a boolean flowfield).
  2. Try to make UpdateItemVariantAttributeFromItem(ItemCode) apply attributes to
    leaf variants only.
  3. Observe that there is no event to hook into the per-variant loop, and that the
    per-variant overload is local and cannot be called or subscribed to.
  4. The only remaining option is to copy the entire standard logic into a custom
    codeunit — which is exactly what we had to do.

Additional context

Additional context

We model item variants as a hierarchy in which only end-level (leaf) variants may
carry attributes, while intermediate variants must stay attribute-free. Because the
processing loop offers no extension point, we currently maintain a full copy of the
standard attribute logic solely to add this one filtering step. This duplicated code
must be re-validated with every Base Application update.

The requested event is minimal, backward-compatible, and follows the existing
OnBefore…OnBeforeLoopIteration + IsHandled pattern already used elsewhere in
this codeunit (e.g. OnBeforeInsertCategoryItemsAttributeValueMapping). It would
allow us to delete our duplicated implementation and rely on the standard logic.

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI-TriageManually trigger or re-trigger an AI triage assessmentSCMGitHub request for SCM area

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions