procedure AssignLineDimension(DocumentType: Integer; DocumentNumber: Code[20]; LineNo: Integer; DimensionCode: Code[20]; DimensionValue: Code[20]); var TempDimSetEntry: Record "Dimension Set Entry" temporary; PurchaseLine: Record "Purchase Line"; DimMgt: Codeunit DimensionManagement; NewDimSetID: Integer; OldDimSetID: Integer; begin PurchaseLine.Get(DocumentType, DocumentNumber, LineNo); //obtain current line dimension set id and its dimensions OldDimSetID := PurchaseLine."Dimension Set ID"; DimMgt.GetDimensionSet(TempDimSetEntry, OldDimSetID); //assign new/update existing dimension with data from external system TempDimSetEntry.Reset(); TempDimSetEntry.SetRange("Dimension Code", DimensionCode); if TempDimSetEntry.FindFirst() then begin TempDimSetEntry.Validate("Dimension Value Code", DimensionValue); TempDimSetEntry.Modify(); end else begin TempDimSetEntry.Init(); TempDimSetEntry.Validate("Dimension Code", DimensionCode); TempDimSetEntry.Validate("Dimension Value Code", DimensionValue); TempDimSetEntry.Insert(); end; //obtain DimSetID after line dimension update NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry); //update line dimension set id if OldDimSetID <> NewDimSetID then begin PurchaseLine."Dimension Set ID" := NewDimSetID; PurchaseLine.Modify(); end; //update line's global dimensions DimMgt.UpdateGlobalDimFromDimSetID(PurchaseLine."Dimension Set ID", PurchaseLine."Shortcut Dimension 1 Code", PurchaseLine."Shortcut Dimension 2 Code"); end;
... //update line's global dimensions GLSetup.Get(); if DimensionCode = GLSetup."Global Dimension 1 Code" then begin PurchaseLine.Validate("Shortcut Dimension 1 Code", DimensionValue); PurchaseLine.Modify(); end; if DimensionCode = GLSetup."Global Dimension 2 Code" then begin PurchaseLine.Validate("Shortcut Dimension 2 Code", DimensionValue); PurchaseLine.Modify(); end; //obtain DimSetID after line dimension update ...
Answers
Dimension 1 = field 1 and so on
It's used to point the dimension value to the correct dimension code
That is correct
This way, the onValidate trigger of the table field handles the call to DimMgt.ValidateShortcutDimValues