Tuesday 24 March 2020

Create display value for default dimension. in D365 FO

public static void main(Args _args)
    {
        str                        dimMainAcc, dimCostCenter, dimDivision, dimLocation;
        CustTable            custTable = CustTable::find("SL0008"); // Add the CustAccount value.

        DimensionAttributeValueSetStorage   davss = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
        int                                 i;

        for (i= 1; i <= davss.elements(); i++)
        {
             //You can add/update dimension values as per the dimension structure in the system.
            if (DimensionAttribute::find(davss.getAttributeByIndex(i)).Name == "MainAccount")
            {
                dimMainAcc = davss.getDisplayValueByIndex(i);
            }
            if (DimensionAttribute::find(davss.getAttributeByIndex(i)).Name == "CostCenter")
            {
                dimCostCenter = davss.getDisplayValueByIndex(i);
            }
            if (DimensionAttribute::find(davss.getAttributeByIndex(i)).Name == "Division")
            {
                dimDivision = davss.getDisplayValueByIndex(i);
            }
            if (DimensionAttribute::find(davss.getAttributeByIndex(i)).Name == "Location")
            {
                dimLocation = davss.getDisplayValueByIndex(i);
            }
        }

        str dimStorageValue = "-" + dimMainAcc + "-" + dimCostCenter + "-" + dimDivision + "-" + dimLocation;

        Info(dimStorageValue);
    }

No comments:

Post a Comment

Insert/Update or remove the default dimension value in D365 FSCM via x++

Use below method to insert/update the dimension values, just pass the parameter values to the method and it will return the updated value: p...