Показать сообщение отдельно
Старый 21.10.2020, 09:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
dynamicsaxinsight: Validate individual financial dimensions
Источник: https://dynamicsaxinsight.wordpress....al-dimensions/
==============

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:

/// /// ValidatedWrite event handler/// /// /// [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);}

Источник: https://dynamicsaxinsight.wordpress....al-dimensions/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.