microsoft / microsoft/BCApps

[Bug]: Shortcut Dimension 1 and 2 code is empty after validating location

Open Beginner friendly
#9,785 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Ownership: Manual Team: SCM
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Describe the issue

Approved: https://github.com/microsoft/BusinessCentralApps/issues/1846

When the user changes "Location Code" on a "Prod. Order Component". Shortcut dimension 1 and 2 is blank even when dimension set id has a value. And the dimension set contains shortcut dimension 1 or 2, or both.

Expected behavior

Shortcut dimension 1 and 2 should have a value when the dimension set id contains values for one or both of these dimensions.

Steps to reproduce

Go to a released production order.
Open the card page.
Make sure the production order line has dimension set id that contains dimension 1 or 2.
On the line click the action to show components.
Add an item then change the location.
Make sure that both the item and the location does NOT have any default dimensions.
If they have a default dimension it works as expected.

Additional context

The issue seems to be that when procedure CreateDimFromDefaultDim is called in table "Prod. Order Component", every place except after calling the procedure from OnValidate on the "Location Code" field. This line is called after.

DimMgt.UpdateGlobalDimFromDimSetID("Dimension Set ID", "Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");

This procedure updates shortcut dimension 1 and 2. Because this is missing, they are never updated.

From OnValidate for the "Location Code" field.

        field(30; "Location Code"; Code[10])
        {
            Caption = 'Location Code';
            TableRelation = Location where("Use As In-Transit" = const(false));

            trigger OnValidate()
            begin
                if Item."No." <> "Item No." then
                    Item.Get("Item No.");

                UpdateUnitCost();
                Validate("Expected Quantity");

                if Item.IsInventoriableType() then begin
                    GetDefaultBin();
                    ProdOrderWarehouseMgt.ProdComponentVerifyChange(Rec, xRec);
                end;
                ProdOrderCompReserve.VerifyChange(Rec, xRec);
                GetUpdateFromSKU();
                CreateDimFromDefaultDim();
            end;
        }
        field(31; "Shortcut Dimension 1 Code"; Code[20])

The procedure GetRecDefaultDimID, called from CreateDim, that is called from CreateDimFromDefaultDim, manages to update shortcut dimension 1 and 2, only if the dimension sources (item or location) has default dimension. Since the prod. order line has dimension set id, the prod. order component tries to inherit the dimensions of the prod. order line. But because of this bug, only the dimension set id is updated.

I will provide a fix for a bug
  • I will provide a fix for a bug

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

Start with table "Prod. Order Component", especially the OnValidate trigger for "Location Code" and the CreateDimFromDefaultDim procedure. Compare the other call sites mentioned in the issue, reproduce the released production-order scenario with inherited dimensions, and verify that Shortcut Dimension 1 and 2 are populated after changing the location.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.