Wednesday, April 24, 2013

Dynamics AX 2012 Excel Add-in - Issues and Solutions (Method UpdateRecIdVisibility not found)

Dynamics AX 2012 Excel Add-in – Issues and Solutions (Method not found: ‘Void Microsoft.Dynamics.AX.Framework.OfficeAddin.DataSourceContainer.UpdateRecIdVisibility(Boolean))
Purpose: The purpose of this document is to outline some issues you may encounter when using Dynamics AX 2012 Excel Add-in for import of data and provide solutions to resolve them.
 
Issue: ‘Method not found: ‘Void Microsoft.Dynamics.AX.Framework.OfficeAddin.DataSourceContainer.UpdateRecIdVisibility(Boolean)’
 
Reason: After you initially install Microsoft Dynamics AX 2012 R2 Office Add-ins and then install Microsoft Dynamics AX 2012 R2 CU1 the old Microsoft Dynamics AX 2012 R2 DLLs related to Office Add-ins may still be present in the file system. The system uses old Microsoft Dynamics AX 2012 R2 DLLs related to Office Add-ins DLLs which causes this issue
 
Dynamics AX Error
 
For example, on the latest (as of today, April 24, 2013) Microsoft Dynamics AX 2012 R2 CU1 Demo VM this error occurs when you launch Excel 2013, define connection Options and then try to Add Table or Add Data  
 
Please note that Microsoft Dynamics AX 212 R2 CU1 build number is 6.2.1000.156
 
In fact if you look for UpdateRecIdVisibility method in Microsoft Dynamics AX 2012 R2 CU1 Microsoft.Dynamics.AX.Framework.OfficeAddin.dll assembly you will be able to find it there
 
So the real problem is in the fact that the system uses old Microsoft Dynamics AX 2012 R2 Microsoft.Dynamics.AX.Framework.OfficeAddin.dll assembly instead of new one
 
Please note that Microsoft Dynamics AX 212 R2 build number is 6.2.158.0
 
And if you check the version of Microsoft.Dynamics.AX.Framework.OfficeAddin.dll assembly
 
in C:\Windows\Microsoft.NET\assembly\GAC_MSIL folder
 
You will see that it’s 6.2.158.0 which corresponds to Microsoft Dynamics AX 2012 R2
 
Solution: Please delete highlighted above Microsoft.Dynamics.AX.Framework.Office.Addin folders in C:\Windows\Microsoft.NET\assembly\GAC_MSIL folder to get rid of old versions of DLLs   
 
If you get a message that Microsoft.Dynamics.AX.Framework.Office.Addin.dll is being used by another process when you try to delete it, please stop Microsoft Dynamics AX AOS and try again
 
Result: As the result you will be able to Add Tables and Add Data in Excel workbook
 
Options
 
Add Tables
 
Field Chooser
 
Specials Thanks is for Chris and Jason for helping to resolve this issue
Please check out Chris’ blog for more interesting articles here: http://blogs.msdn.com/b/chrisgarty/
 
Tags: Dynamics ERP, Dynamics AX 2012, Excel, Dynamics AX 2012 Excel Add-in, Data Import, Data Conversion, Data Migration, Application Integration Framework, Issue, Problem, Solution, Resolution.
 
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
 
 

Monday, October 22, 2012

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

Microsoft Dynamics AX 2012
Excel Add-in – Questions and Answers (Business 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 can I execute additional business logic using Microsoft Dynamics AX 2012 Excel Add-in?
 
Answer: Microsoft Dynamics AX 2012 Excel Add-in uses AIF Web Services for publishing the data into Microsoft Dynamics AX 2012. In order to automate certain processes or execute additional business logic you can override updateNow method in appropriate AIF Document class and implement necessary business logic in X++. In this document to illustrate main concepts I will use General journal (LedgerGeneralJournalService) and Customer Payment journal (LedgerCustPaymJournalService) Web Services in Microsoft Dynamics AX 2012.
 
Details
 
Every AIF Web Service has corresponding Document class in AOT, usually these classes are prefixed with Axd. For example, General journal Web Service Document class is AxdLedgerGeneralJournal class and Customer Payment journal Web Service Document class is AxdCustPaymJournal class. Focusing on Business Logic aspect in this investigation we'll take a closer look at Framework classes implementing create and update operations.
 
Classes\AxdBaseCreate\Methods\deserializeDocument
 
Call Stack:
<![if !supportLists]>-          <![endif]>Classes\AxdBase\Methods\updateNow
<![if !supportLists]>-          <![endif]>Classes\AxdBaseUpdate\Methods\postProcessDocument
<![if !supportLists]>-          <![endif]>Classes\AxdBaseUpdate\Methods\deserializeDocument
<![if !supportLists]>-          <![endif]>Classes\AxdBaseCreate\Methods\createDocumentList
<![if !supportLists]>-          <![endif]>Classes\AxdBase\Methods\createList
<![if !supportLists]>-          <![endif]>Classes\AifDocumentService\Methods\createList
 
Classes\AxdBaseUpdate\Methods\postProcessDocument
 
Call Stack:
<![if !supportLists]>-          <![endif]>Classes\AxdBase\Methods\updateNow
<![if !supportLists]>-          <![endif]>Classes\AxdBaseUpdate\Methods\postProcessDocument
<![if !supportLists]>-          <![endif]>Classes\AxdBaseUpdate\Methods\deserializeDocument
<![if !supportLists]>-          <![endif]>Classes\AxdBaseUpdate\Methods\updateDocumentList
<![if !supportLists]>-          <![endif]>Classes\AxdBase\Methods\updateList
<![if !supportLists]>-          <![endif]>Classes\AifDocumentService\Methods\updateList
 
updateNow method in Document class will be executed as a last step (post-processing) after AIF message processing which allows you to execute additional business logic
 
For example, after General journal will be created or updated via General journal Web Service certain fields such as Journal balance, etc will be updated
 
Classes\AxdLedgerGeneralJournal\Methods\updateNow
 
For comparison in Rich Client when you post General journal Journal balance update is triggered from Form in "Validate" (and "Post") button clicked method
 
Forms\LedgerJournalTransDaily\Designs\DesignList\ButtonCheckJournal\Methods\clicked
 
Another example is Customer Payment journal when after its creation or update in certain scenarios it may be necessary to generate Settlements against Customer invoices
 
Classes\AxdCustPaymJournal\Methods\updateNow
 
Typical requirement for automation is when you need to automatically post General journal after its successful creation. Please see below how you can implement this requirement in Microsoft Dynamics AX 2012
 
LedgerJournalPost::postJournal(LedgerJournalTable, false);
 
Classes\AxdLedgerGeneralJournal\Methods\updateNow
 
If you face with this requirement I'd also recommend introducing dedicated parameter in UI to control whether it's required or not to automatically post General journal when General journal AIF Web Service is invoked
 
Once you change necessary Document class please generate CIL because all AIF Web Services related code in Microsoft Dynamics AX 2012 is executed in CIL on the server
 
Please also note that if you use Tables (Add Tables) in Microsoft Dynamics AX 2012 Excel Add-in the system will use Generic Document Web Service at the back-end
 
Version: Microsoft Dynamics AX 2012 R2
 
Tags: Dynamics ERP, Dynamics AX 2012, Excel, Dynamics AX 2012 Excel Add-in, Data Import, Data Conversion, Data Migration, Application Integration Framework, Question, Answer, Business 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

Sunday, October 21, 2012

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

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