Sunday, June 23, 2019

How to create a Dimension Value using x++ D365 FO

There are lot of tables holding values for Financial Dimensions such as DimensionAttributeValue and DimensionAttributeValueCombination but in case if we can't find the values in these above tables then we have another table known as DimensionFinancialTag through which we can get values as well as we can create new dimensions as well.


Here is an example mentioned below :-

        
 DimDetails                                          dimensiondetails;
 DimensionAttribute                             dimAttr;
 DimensionAttributeValue                    dimAttrValue;
 DimensionDefault                                result;
 DimensionFinancialTag                       dimFinTag , dimFinTagval;
 RecId                                                    dimFinancialCategoryRecid;
        
DimensionAttributeValueSetStorage   valueSetStorage = new 

DimensionAttributeValueSetStorage();

        try
        {
        dimAttr = DimensionAttribute::findByName('ABC');
        dimFinancialCategoryRecid = dimAttr.financialTagCategory();
        while select dimensiondetails where dimensiondetails.UpdateFlag==0
        {
            select dimFinTag where
                   dimFinTag.FinancialTagCategory == dimFinancialCategoryRecid &&
                   dimFinTag.Value == dimensiondetails.AssetCode;

            if(!dimFinTag.RecId)
            {
                dimFinTagval.Value = dimensiondetails.AssetCode;
                dimFinTagval.Description = dimensiondetails.AssetDescription;
                dimFinTagval.FinancialTagCategory = dimFinancialCategoryRecid;
                dimFinTagval.insert();
                
            }

            
        }

        }

        catch(Exception::Error)
        {
            ttsAbort;
            throw Exception::Error;
        }

No comments:

Post a Comment

Demystifying the SysOperation Framework in D365 F&O: Building Scalable and Maintainable Batch Jobs

 If you've been developing in Dynamics 365 Finance and Operations for a while, chances are you've either worked with or heard about ...