table 50139 "Header Table"
{
DataClassification = SystemMetadata;
fields
{
field(1; "Entry No."; Integer)
{
DataClassification = SystemMetadata;
}
field(2; "Name"; Text[100])
{
DataClassification = SystemMetadata;
}
field(3; "Shortcut Dimension 1 Code"; Code[20])
{
CaptionClass = '1,2,1';
Caption = 'Shortcut Dimension 1 Code';
TableRelation = "Dimension Value".Code where(
"Global Dimension No." = const(1),
Blocked = const(false));
trigger OnValidate()
begin
ValidateShortcutDimCode(1, "Shortcut Dimension 1 Code");
end;
}
field(4; "Shortcut Dimension 2 Code"; Code[20])
{
CaptionClass = '1,2,2';
Caption = 'Shortcut Dimension 2 Code';
TableRelation = "Dimension Value".Code where(
"Global Dimension No." = const(2),
Blocked = const(false));
trigger OnValidate()
begin
ValidateShortcutDimCode(2, "Shortcut Dimension 2 Code");
end;
}
field(5; "Dimension Set ID"; Integer)
{
Caption = 'Dimension Set ID';
Editable = false;
TableRelation = "Dimension Set Entry";
trigger OnLookup()
begin
ShowDimensions();
ShowDocDim();
end;
trigger OnValidate()
begin
DimensionManagement.UpdateGlobalDimFromDimSetID("Dimension Set ID", "Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");
end;
}
}
keys
{
key(Key1; "Entry No.")
{
Clustered = true;
}
}
procedure ShowDocDim()
var
OldDimSetID: Integer;
begin
OldDimSetID := "Dimension Set ID";
"Dimension Set ID" :=
DimMgt.EditDimensionSet(
Rec, "Dimension Set ID", StrSubstNo('%1 %2', "Entry No.", Name),
"Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");
if OldDimSetID <> "Dimension Set ID" then begin
Modify();
UpdateAllLineDim("Dimension Set ID", OldDimSetID);
end;
end;
trigger OnInsert()
begin
ValidateShortcutDimCode(1, "Shortcut Dimension 1 Code");
ValidateShortcutDimCode(2, "Shortcut Dimension 2 Code");
end;
var
DimensionManagement: Codeunit DimensionManagement;
DimMgt: Codeunit DimensionManagement;
procedure ValidateShortcutDimCode(FieldNumber: Integer; var ShortcutDimCode: Code[20])
var
OldDimSetID: Integer;
begin
OldDimSetID := "Dimension Set ID";
DimMgt.ValidateShortcutDimValues(FieldNumber, ShortcutDimCode, "Dimension Set ID");
if OldDimSetID <> "Dimension Set ID" then begin
Modify();
UpdateAllLineDim("Dimension Set ID", OldDimSetID);
end;
end;
procedure UpdateAllLineDim(NewParentDimSetID: Integer; OldParentDimSetID: Integer)
var
Line: Record "Line Table";
ATOLink: Record "Assemble-to-Order Link";
xLine: Record "Line Table";
NewDimSetID: Integer;
ShippedReceivedItemLineDimChangeConfirmed: Boolean;
IsHandled: Boolean;
begin
if NewParentDimSetID = OldParentDimSetID then
exit;
if not ConfirmUpdateAllLineDim(NewParentDimSetID, OldParentDimSetID) then
exit;
Line.Reset();
Line.SetRange("Entry No.", "Entry No.");
Line.LockTable();
if Line.Find('-') then
repeat
NewDimSetID := DimMgt.GetDeltaDimSetID(Line."Dimension Set ID", NewParentDimSetID, OldParentDimSetID);
if Line."Dimension Set ID" <> NewDimSetID then begin
xLine := Line;
Line."Dimension Set ID" := NewDimSetID;
DimMgt.UpdateGlobalDimFromDimSetID(
Line."Dimension Set ID", Line."Shortcut Dimension 1 Code", Line."Shortcut Dimension 2 Code");
Line.Modify();
end;
until Line.Next() = 0;
end;
local procedure ConfirmUpdateAllLineDim(NewParentDimSetID: Integer; OldParentDimSetID: Integer) Confirmed: Boolean;
var
Text064: Label 'You may have changed a dimension.\\Do you want to update the lines?';
begin
Confirmed := Confirm(Text064);
end;
procedure ShowDimensions()
var
IsHandled: Boolean;
begin
IsHandled := false;
if IsHandled then
exit;
"Dimension Set ID" :=
DimensionManagement.EditDimensionSet(
Rec, "Dimension Set ID", StrSubstNo('%1 %2', "Entry No.", Name),
"Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");
end;
}
Line Table:
table 50140 "Line Table"
{
DataClassification = ToBeClassified;
fields
{
field(1; "Entry No."; Integer)
{
DataClassification = ToBeClassified;
}
field(2; "Line No."; Integer)
{
DataClassification = ToBeClassified;
}
field(3; "Shortcut Dimension 1 Code"; Code[20])
{
CaptionClass = '1,2,1';
Caption = 'Shortcut Dimension 1 Code';
TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(1),
Blocked = CONST(false));
trigger OnValidate()
begin
ValidateShortcutDimCode(1, "Shortcut Dimension 1 Code");
end;
}
field(4; "Shortcut Dimension 2 Code"; Code[20])
{
CaptionClass = '1,2,2';
Caption = 'Shortcut Dimension 2 Code';
TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(2),
Blocked = CONST(false));
trigger OnValidate()
begin
ValidateShortcutDimCode(2, "Shortcut Dimension 2 Code");
end;
}
field(5; "Dimension Set ID"; Integer)
{
Caption = 'Dimension Set ID';
Editable = false;
TableRelation = "Dimension Set Entry";
trigger OnLookup()
begin
ShowDimensions();
end;
trigger OnValidate()
begin
DimMgt.UpdateGlobalDimFromDimSetID("Dimension Set ID", "Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");
end;
}
}
keys
{
key(Key1; "Entry No.", "Line No.")
{
Clustered = true;
}
}
procedure ShowDimensions() IsChanged: Boolean
var
OldDimSetID: Integer;
IsHandled: Boolean;
begin
OldDimSetID := "Dimension Set ID";
"Dimension Set ID" :=
DimMgt.EditDimensionSet("Dimension Set ID", StrSubstNo('%1 %2', "Entry No.", "Line No."));
DimMgt.UpdateGlobalDimFromDimSetID("Dimension Set ID", "Shortcut Dimension 1 Code", "Shortcut Dimension 2 Code");
end;
var
DimMgt: Codeunit DimensionManagement;
procedure ValidateShortcutDimCode(FieldNumber: Integer; var ShortcutDimCode: Code[20])
var
IsHandled: Boolean;
begin
IsHandled := false;
DimMgt.ValidateShortcutDimValues(FieldNumber, ShortcutDimCode, "Dimension Set ID");
end;
}
On your header card/document page, along your dimension fields, you can also have this action that will open "Dimension Set Entries" page
actions
{
area(processing)
{
action(Dimensions)
{
AccessByPermission = TableData Dimension = R;
ApplicationArea = Dimensions;
Caption = 'Dimensions';
PromotedCategory = Process;
Promoted = true;
PromotedOnly = true;
Image = Dimensions;
ShortCutKey = 'Alt+D';
ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';
trigger OnAction()
begin
Rec.ShowDimensions();
CurrPage.SaveRecord();
end;
}
}
}
Result:
I have did a lot of work for you today I wish you will like and confirms that my effort works for you.