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);
    }
  • 相关阅读:
    Annual Summary-2019
    (翻译向)kafka--简介篇1
    mysql 查看数据库大小
    nohup保证程序后台运行
    NLP(四):文本向量化word2vec
    NLP(三):关键词提取
    NLP(二):jieba高频词提取
    NLP(一):jieba分词
    爬虫(一)百度翻译
    【论文笔记】社交网络中的信息扩散分析及其应用研究
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/13984486.html
Copyright © 2011-2022 走看看