Add Financial dimension to Customer/Vender with X++ Dynamics 365 for finance and operations

Small tip, I used following code snippet to add financial dimension in Customer / Vendor, You can extend this code by adding more dimension and values on Containers in following code snippet.


public class  iaxFinancialDimensionHelper
{


    Public static DimensionDefault ProjectDimension(ProjId _ProjId)
    {
    
        DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
        DimensionDefault result;
        int i;
        DimensionAttribute dimensionAttribute;
        DimensionAttributeValue dimensionAttributeValue;
        container conAttr = [“Projects”]; 
        container conValue = [_ProjId]; 
        str dimValue;
        for (i = 1; i <= conLen(conAttr); i++)
        {
            dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
            if (dimensionAttribute.RecId == 0)
            {
                continue;
            }
            dimValue = conPeek(conValue,i);
            if (dimValue != “”)
            {
                // The last parameter is “true”. A dimensionAttributeValue record will be created if not //found.
                dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
                // Add the dimensionAttibuteValue to the default dimension
                valueSetStorage.addItem(dimensionAttributeValue);
            }
        }
        result = valueSetStorage.save();
        return result;
    
    }


}

Reference : Internet. possible Dynamics forum. it works for me.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *