lingdanglfw(DAX)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

Validate Finance Dimension on D365FO

Purpose:

The purpose of this post is to demonstrate how we can validate individual financial dimension values before writing a customer record.

Product:

Dynamics 365 for Finance and Operations

Description:

The code below validates some customer fields like Site, Warehouse, Price group and then checks the values for individual financial dimensions in this case which custom dimensions, Channel and Industry.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/// <summary>
/// ValidatedWrite event handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(CustTable), DataEventType::ValidatedWrite)]
public static void CustTable_onValidatedWrite(Common sender, DataEventArgs e)
{
    #define.DimAttrNameChannel('Channel')
    #define.DimAttrNameIndustry('Industry')
     
    CustTable custTable = sender as CustTable;
    ValidateEventArgs event = e as ValidateEventArgs;
    DimensionAttributeValueSet dimensionAttributeValueSet;
    DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
    DimensionAttributeValue dimensionAttributeValue;
    DimensionAttribute dimensionAttribute;
    DimensionAttributeValueSetStorage dimAttrValueSetStorage;
     
    boolean result = event.parmValidateResult();
     
    if (!custTable.InventSiteId)
    {
        result = checkFailed(strFmt("Site is required."));
    }
 
    if (!custTable.InventLocation)
    {
        result = checkFailed(strFmt("Warehouse is required."));
    }
 
    if (!custTable.PriceGroup)
    {
        result = checkFailed(strFmt("Price is required."));
    }
 
    if (!custTable.DefaultDimension)
    {
        result = checkFailed(strFmt("Financial dimensions Channel and Industry are required."));
    }
    else
    {
        dimAttrValueSetStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
        dimensionAttribute = DimensionAttribute::findByName(#DimAttrNameChannel);
 
        if (!dimAttrValueSetStorage.containsDimensionAttribute(dimensionAttribute.RecId))
        {
            result = checkFailed(strFmt("Financial dimensions Channel is required."));
        }
 
        dimensionAttribute = DimensionAttribute::findByName(#DimAttrNameIndustry);
 
        if (!dimAttrValueSetStorage.containsDimensionAttribute(dimensionAttribute.RecId))
        {
            result = checkFailed(strFmt("Financial dimensions Industry is required."));
        }
    }
 
    event.parmValidateResult(result);
}

posted on   lingdanglfw  阅读(110)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示