最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Get default financial dimension values through X++ code

网络文摘 William 5616浏览 0评论

This topic is not new and we have lots of blogs available on it. Yasir Co-blogger also explained this quite well in his blog. The purpose to share this again here that I have did some minor modifications in his job to get both attributes (Value and Name) for Default dimension. Complete code is here.

static void GetDefaultDimensionAttributeName(Args _args)
{
    DimensionAttributeValueSetStorage    dimStorage;
    HcmPositionDefaultDimension          HcmPositionDefaultDimension;
    DimensionAttribute  DimensionAttribute;
    Counter                                               i;
    DimensionAttribute          dimAttr;
    DimensionAttributeValue     dimAttrValue;
    Common                      common;
    DictTable                   dictTable;
    str                         Name;
    str                         value;

    // get the dimension value from position    
    HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(HcmPosition::findByPosition("000001").RecId,CompanyInfo::find().RecId);

    // make the dimension storage object    
    dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        // get attribute select here.
        select firstonly dimAttrValue
        where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
        join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

        if (dimAttr && dimAttrValue)
        {
            dictTable = new DictTable(dimAttr.BackingEntityType);
            common = dictTable.makeRecord();

            if (common.TableId)
            {
                select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                name = common.(dimAttr.NameAttribute);
                value = common.(dimAttr.ValueAttribute);
            }
        }
        info(dimAttr.Name +"----" +value + "----"+name);
    }
}

output image
i9

we can check the other examples on same topic from Yasir’s Blog – Microsoft Dynamics AX


发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址