zoukankan      html  css  js  c++  java
  • 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:

    /// <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);
    }
  • 相关阅读:
    14 break
    13 for循环
    Python 3.7 将引入 dataclass 装饰器
    工程师如何在面试中脱颖而出
    如何避免 async/await 地狱
    命令行里打 cd 简直是浪费生命
    GitHub 十大 CI 工具
    GitHub CEO:GitHub 十年,感谢有你
    如何在 2 分钟内入睡(二战时期美国飞行员训练法)
    一分钟了解 TCP/IP 模型
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/13984486.html
Copyright © 2011-2022 走看看