Microsoft Dynamics AX 2012
Excel Add-in – Questions and Answers (Related Records)
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 deal with Related Records?
Answer: The way the system implements Related records 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 Sales order (SalesTable/SalesLine) and Purchase order (PurchTable/PurchLine) business entities in Microsoft Dynamics AX 2012.
Details
SalesTable/SalesLine and PurchTable/PurchLine Tables in Microsoft Dynamics AX 2012 have corresponding AxSalesTable/AxSalesLine and AxPurchTable/AxPurchLine AIF Proxy classes. 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 Related records in this investigation we'll take a closer look at createOrUpdateRelatedRecords method where Related records logic is usually implemented.
Sales order – Sales line and Purchase order – Purchase line
Data Model
In Microsoft Dynamics AX 2012 you can add Miscellaneous charges to Sales order/line and Purchase order/line. MarkupTrans Table contains all types of Miscellaneous charges transactions and references to the original document by TableID/RecID (TransTableID/TransRecID).
Rich Client
Out-of-the-box in Rich Client once you change Charges group on Sales order MarkupTrans record(s) may be automatically populated based on predefined rules (Automatic charges)
This is triggered in update method of SalesTableType class
Classes\SalesTableType\Methods\update
Call Stack:
<![if !supportLists]>- <![endif]>Classes\Markup\insertMarkupTrans
<![if !supportLists]>- <![endif]>Tables\SalesTable\Methods\createMarkupTrans
<![if !supportLists]>- <![endif]>Classes\SalesTableType\Methods\update
<![if !supportLists]>- <![endif]>Tables\SalesTable\Methods\update
<![if !supportLists]>- <![endif]>Forms\SalesTable\Data Sources\SalesTable\Methods\update
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 manipulation (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 trigger Related records logic from Form interactively. For example, when the record is changed on Form Data source update method on respective Data source (and update methods on Table) will be executed.
Excel Add-in
Sales line – Miscellaneous charges
Call Stack:
<![if !supportLists]>- <![endif]>Classes\AxSalesLine\createOrUpdateRelatedRecords
<![if !supportLists]>- <![endif]>Classes\AxInternalBase\doSave
<![if !supportLists]>- <![endif]>Classes\AxInternalBase\save
…
Please note that as soon as Excel Add-in uses formal AIF interface Related records will be populated when you publish data into Microsoft Dynamics AX 2012.
Purchase order – Purchase line
Rich Client
Similarly once you change Charges group on Purchase order MarkupTrans record(s) may be automatically populated based on predefined rules (Automatic charges)
This is triggered in update method of PurchTableType class
Classes\PurchTableType\Methods\update
Call Stack:
<![if !supportLists]>- <![endif]>Classes\Markup\insertMarkupTrans
<![if !supportLists]>- <![endif]>Tables\PurchTable\Methods\createMarkupTrans
<![if !supportLists]>- <![endif]>Classes\PurchTableType\Methods\update
<![if !supportLists]>- <![endif]>Tables\PurchTable\Methods\update
<![if !supportLists]>- <![endif]>Forms\PurchTable\Data Sources\PurchTable\Methods\update
Excel Add-in
Purchase line – Miscellaneous charges
Call Stack:
<![if !supportLists]>- <![endif]>Classes\AxPurchLine\createOrUpdateRelatedRecords
<![if !supportLists]>- <![endif]>Classes\AxInternalBase\doSave
<![if !supportLists]>- <![endif]>Classes\AxInternalBase\save
…
Please note that Related records logic will be executed after Defaulting logic when data is published into Microsoft Dynamics AX 2012 through AIF interface.
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, Related Records.
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