Monday, 25 May 2026

Check Mandatory Product Dimensions in d365 Fo using X++

 public void checkMandatoryProductDimensions(ItemId _itemId)

{

    InventTable                   inventTable = InventTable::find(_itemId);

    EcoResProductDimensionGroup   ecoResProductDimGroup;

    EcoResProductDimensionGroupSetup  dimGroupSetup;


    if (inventTable)

    {

        // Get the Product Dimension Group linked to the Item

        select firstonly ecoResProductDimGroup

            where ecoResProductDimGroup.RecId == inventTable.ProductDimensionGroup;


        if (ecoResProductDimGroup)

        {

            // Join the setup table to see which dimensions are active/mandatory

            while select dimGroupSetup

                where dimGroupSetup.ProductDimensionGroup == ecoResProductDimGroup.RecId

            {

                if (dimGroupSetup.IsActive)

                {

                    Info(strFmt("Dimension: %1 | Is Mandatory: %2", 

                        dimGroupSetup.DimensionAttribute, 

                        dimGroupSetup.IsMandatory ? "Yes" : "No"));

                }

            }

        }

        else

        {

            Warning("No Product Dimension Group assigned to this item.");

        }

    }

}


No comments:

Post a Comment

Display Method Data Not Showing in Query-Based SSRS Reports in D365 FO

 While working on a Query-Based SSRS Report in Dynamics 365 Finance & Operations, I faced an issue where a display method added through ...