我的问题是设置从外部源读取的一些尺寸值。
鉴于 AX 2009 声明:
ledgerJournalTrans.Dimension = ledgerTable.Dimension;
ledgerJournalTrans.Dimension[1] = "abc";
与 AX 2012 中的等效方法是什么?
这自然会假设存在“部门”维度作为第一维度。
首先,AX 2009 中的遗留尺寸已完全重做并更换在 AX 2012 中。新的 LedgerDimension 是基于帐户结构和高级规则结构所需的帐户和旧维度值的组合。要了解有关 AX 2012 中新维度框架的更多信息,请尝试阅读白皮书关于新维度框架。
假设 Department 是第一个维度,并且两个维度都使用 LedgerDimensionAccount EDT,可以大大简化此场景,但新的维度框架非常灵活,因此此假设可能不正确。即使是这样,简单地为 Department 指定一个新值可能会要求组合结构需要发生巨大变化,因为可以设置高级规则结构。
诚实地,我只会将下面的代码视为一些基础知识如何工作的演示,而不是应该在生产中使用的代码。话虽如此,如果 LedgerTable 上的 Dimension 字段已使用存储完整组合的 LedgerDimensionAccount EDT 替换为 LedgerDimension 字段,则此代码应该可以实现您想要的效果。
DimensionStorage dimensionStorage;
DimensionAttribute deparmentDimensionAttribute;
DimensionAttributeValue newDepartmentValue;
// Find the deparment dimension attribute
deparmentDimensionAttribute = DimensionAttribute::findByName("Department");
// Find the new department value we want to put in the new combination.
newDepartmentValue = DimensionAttributeValue::findByDimensionAttributeAndValue(deparmentDimensionAttribute, "abc");
// Load a DimensionStorage instance with the old combination and update the first segment with new value
dimensionStorage = DimensionStorage::findById(ledgerTable.LedgerDimension);
dimensionStorage.setSegment(1,DimensionStorageSegment::constructFromValue("abc", newDepartmentValue));
ledgerJournalTrans.LedgerDimension = dimensionStorage.save();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)