Table 350 Dimension Combination, source in 29

Source29

src/Layers/W1/BaseApp/Finance/Dimension/DimensionCombination.Table.al82 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Finance.Dimension;

/// <summary>
/// Defines restrictions on combinations of two dimensions to prevent invalid or undesired dimension pairings.
/// Controls whether specific dimension combinations are limited or completely blocked during posting validation.
/// </summary>
/// <remarks>
/// Used by dimension management validation to enforce business rules on dimension combinations.
/// Automatically manages related dimension value combinations when dimension combinations are deleted.
/// Supports both limited and blocked restriction types for flexible dimension control.
/// </remarks>
table 350 "Dimension Combination"
{
    Caption = 'Dimension Combination';
    DataClassification = CustomerContent;

    fields
    {
        /// <summary>
        /// Code of the first dimension in the restricted combination pair.
        /// </summary>
        field(1; "Dimension 1 Code"; Code[20])
        {
            Caption = 'Dimension 1 Code';
            NotBlank = true;
            TableRelation = Dimension.Code;
        }
        /// <summary>
        /// Code of the second dimension in the restricted combination pair.
        /// </summary>
        field(2; "Dimension 2 Code"; Code[20])
        {
            Caption = 'Dimension 2 Code';
            NotBlank = true;
            TableRelation = Dimension.Code;
        }
        /// <summary>
        /// Type of restriction applied to this dimension combination.
        /// Limited allows specific value combinations; Blocked prevents all combinations.
        /// </summary>
        field(3; "Combination Restriction"; Option)
        {
            Caption = 'Combination Restriction';
            NotBlank = true;
            OptionCaption = 'Limited,Blocked';
            OptionMembers = Limited,Blocked;
        }
    }

    keys
    {
        key(Key1; "Dimension 1 Code", "Dimension 2 Code")
        {
            Clustered = true;
        }
    }

    fieldgroups
    {
    }

    trigger OnDelete()
    var
        DimValueComb: Record "Dimension Value Combination";
    begin
        if "Dimension 1 Code" < "Dimension 2 Code" then begin
            DimValueComb.SetRange("Dimension 1 Code", "Dimension 1 Code");
            DimValueComb.SetRange("Dimension 2 Code", "Dimension 2 Code");
        end else begin
            DimValueComb.SetRange("Dimension 1 Code", "Dimension 2 Code");
            DimValueComb.SetRange("Dimension 2 Code", "Dimension 1 Code");
        end;
        if DimValueComb.FindFirst() then
            DimValueComb.DeleteAll(true);
    end;
}