Quantcast
Channel: Dynamics AX 2012 Data Import using Excel Add-in
Viewing all articles
Browse latest Browse all 41

Microsoft Dynamics AX 2012 Excel Add-in – Questions and Answers (Validation Logic)

$
0
0
Microsoft Dynamics AX 2012
Excel Add-in – Questions and Answers (Validation Logic)
 
Purpose: The purpose of this document is to provide answers to frequently asked questions related to Microsoft Dynamics AX 2012 Excel Add-in.
 
Question: How does Microsoft Dynamics AX 2012 Excel Add-in implement Validation Logic?
 
Answer: The way the system implements Validation logic in Excel Add-in varies depending on AIF proxy classes implementation for particular business entities. In this document to illustrate main concepts I will use General journal (LedgerJournalTrans) business entity in Microsoft Dynamics AX 2012. Also some special controls for interactive validation are provided in Excel Add-in for certain types of information, for example, financial dimensions combinations.
 
Details
 
LedgerJournalTrans Table in Microsoft Dynamics AX 2012 has corresponding AxLedgerJournalTrans AIF Proxy class. All AIF Proxy classes extend AxInternalBase class. AxInternalBase class in its turn implements some core methods related to data manipulation. One of core methods in AxInternalBase class is doSave method. Focusing on Validation logic in this investigation we'll take a closer look at validateFields and validateWrite methods where Validation logic is usually implemented.
 
General journal
 
Rich Client
 
Out-of-the-box in Rich Client on a Form when you change the value for certain field and move the focus to another field the system does auto-save of record and at this time the validation is performed
 
For example, if Currency value is changed on General journal line the system may throw validation error
 
In this particular case X++ validation logic was executed and as the result the user will see the following error
 
Call stack:
<![if !supportLists]>-          <![endif]>Classes\LedgerJournalEngine\currencyModified
<![if !supportLists]>-          <![endif]>Forms\LedgerJournalTrandDaily\Data Sources\LedgerJournalTrans\Fields\CurrencyCode\Methods\modified
 
In some cases validation errors may be caused by data model itself and not X++ validation logic
 
"The currency ALX does not exist" was caused by Relation between Currency and LedgerJournalTrans Tables
 
Tables\LedgerJournalTrans\Relations\Currency
 
X++ validation logic related to LedgerJournalTrans Table can be found in validateField and validateWrite method. validateField is executed when any field is changed and validateWrite method is executed for the entire record upon save 
 
Tables\LedgerJournalTrans\Methods\validateField
 
Tables\LedgerJournalTrans\Methods\validateWrite (validateWrite_Server)
 
Call Stack:
<![if !supportLists]>-          <![endif]>Tables\LedgerJournalTrans\ Methods\validateWrite
<![if !supportLists]>-          <![endif]>Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Methods\validateWrite
<![if !supportLists]>-          <![endif]>Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\ Methods\leaveRecord
 
The principal difference between Rich Client and Excel Add-in is that in Rich Client some code is executed on the client which allows for interactive data validation (stateful behavior) and Excel Add-in will have to go through formal AIF interface every time the data is published into Microsoft Dynamics AX 2012 (stateless behavior). Please note that when you deal with Form in Rich Client you already deal with predefined dataset as opposite to Excel Add-in where you have to define your dataset first. That's why in Rich Client it's possible to execute Validation logic from Form interactively.
 
Excel Add-in
 
AxLedgerJournalTrans AIF Proxy class implements Validation logic in validateField and validateWrite methods
 
Classes\AxLedgerJournalTrans\Methods\validateField
 
Classes\AxLedgerJournalTrans\Methods\validateWrite
 
Please note that validateField and validateWrite methods in AxLedgerJournalTrans AIF Proxy class will eventually trigger validateField and validateWrite methods in LedgerJournalTrans Table
 
Currently out-of-the-box in Microsoft Dynamics AX 2012 R2 (September CTP) LedgerGeneralJournalService Web Service and LedgerJournalTrans Table can't be used due to error shown below
 
General journal – Add Data (LedgerGeneralJournalService)
 
General journal – Add Tables (LedgerJournalTrans)
 
That's why for the sake of General journal Validation logic demo I'll use Microsoft Dynamics AX 2012 FPK
 
Example of X++ validation logic error
 
Before publishing
 
After publishing
 
Example of data model validation logic error
 
Before publishing
 
After publishing
 
Excel Add-in also provides special controls for interactive validation for certain types of information. For example, financial dimension combination may be validated using "Select dimension attribute values" control
 
 
 
Please note that Segmented control in Rich Client shows different value lookup (Ledger account, Vendor, Customer, etc} depending of Account type = {Ledger, Vendor, Customer, etc}, however corresponding "Select dimension attribute values" control in Excel Add-in is only tailored for Ledger accounts 
 
Versions: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 FPK
 
Tags: Dynamics ERP, Dynamics AX 2012, Excel, Dynamics AX 2012 Excel Add-in, Data Import, Data Conversion, Data Migration, Application Integration Framework, Question, Answer, Validation Logic.
 
Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the issues and describe the solutions.
 
Author: Alex Anikiev, PhD, MCP

Viewing all articles
Browse latest Browse all 41

Trending Articles