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

D365FO: 通过 X++ 中获取用于显示的维度值/D365FO: Get dimension display value in X++

网络文摘 William 163浏览 0评论

Purpose:

Demonstrate how can we get dimension display value in X++. This could be pretty handy when we need to display dimension display value on a custom form or an SSRS report for example.

Application:

Dynamics 365 for Finance and Operations

Solution:

You can use the following code to get the dimension display value by passing in default dimension RecId and dimension name string.

Code

/// <summary>
/// Gets dimension display value. Feb 16, 24 MK
/// </summary>
/// <remarks>
/// Gets dimension display value by default dimension and dimension name.
/// </remarks>
public static DimensionValue getDimensionDisplayValue(RecId _defaultDimension, Name _dimName)
{
	DimensionAttributeValueSetStorage dimStorage;

	dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);

	return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(_dimName).RecId);
}

Usage

For example, if you need to get cost center dimension value from a Purchase Order header, then you can get it by passing in the default dimension RecId of PurchTable and cost center dimension string.
#define.CostCenter("CostCenter")


dimCostCenter = MAK_LedgerDimensionHelper::getDimensionDisplayValue(purchTable.DefaultDimension, #CostCenter);
发表我的评论
取消评论

表情

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

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