在D365FO中,集成应用程序的财务维度配置可以设置财务维度的格式,用来方便做数据导入,借助此功能,如果有需求导入带财务维度相关的数据时,
我们可以在集成应用程序的财务维度配置界面,定义我们需要的格式,然后通过以下代码进行调用,就可以生成需要的财务维度的RecId。
[ExtensionOf(tableStr(DimensionHierarchy))]
final class DimensionHierarchyTVya_Extension
{
public static DefaultDimensionIntegrationStructureDisplay getDisplayStringDimensionIntegrationAccountStructure(Name _accountStructure, DimensionHierarchyType _dimensionHierarchyType)
{
DimensionHierarchyIntegration dimensionHierarchyIntegration;
DimensionHierarchy dimensionHierarchy;
DefaultDimensionIntegrationStructureDisplay displayString;
container cachedResult;
;
if (cachedResult == conNull())
{
select firstonly DisplayString from dimensionHierarchyIntegration
join dimensionHierarchy
where dimensionHierarchyIntegration.DimensionHierarchy == dimensionHierarchy.RecId
&& dimensionHierarchy.StructureType == _dimensionHierarchyType
&& dimensionHierarchy.Name;
if (dimensionHierarchyIntegration.RecId)
{
cachedResult = [dimensionHierarchyIntegration.DisplayString];
DimensionCache::insertValue(DimensionCacheScope::DimensionDataEntityIntegrationFormat, [_dimensionHierarchyType], cachedResult);
}
}
displayString = conpeek(cachedResult, 1);
return displayString;
}
}
static void main(Args _args)
{
//Ledger dimension format
LedgerAccountDimensionResolver ledgerAccountDimensionResolver = LedgerAccountDimensionResolver::newResolver("18500|Department|Cost|Item||");
ledgerAccountDimensionResolver.parmDimensionFormat(DimensionHierarchy::getDisplayStringDimensionIntegrationAccountStructure("LedgerDimensionFormat",
DimensionHierarchyType::DataEntityLedgerDimensionFormat));
DimensionDynamicAccount dynamicsDimension = ledgerAccountDimensionResolver.resolve();
//Default dimension
DimensionDefaultResolver dimensionDefaultResolver = DimensionDefaultResolver::newResolver("Department|Cost|Item||");
dimensionDefaultResolver.parmDimensionFormat(DimensionHierarchy::getDisplayStringDimensionIntegrationAccountStructure("DefaultDimensionFormat",
DimensionHierarchyType::DataEntityDefaultDimensionFormat));
DimensionDefault dimensionDefault = dimensionDefaultResolver.resolve();
}