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.
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.
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
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
For comparison in Rich Client when you post General journal Journal balance update is triggered from Form in "Validate" (and "Post") button clicked method
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
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);
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


  1. Really nice post!!! Now a days Microsoft Dynamics AX Implementation is very useful... Thanks for sharing such a great information...

  2. There is a bug in LedgerCustPaymJournalService where payment journals cannot be posted because web service does not set the offset account. So it appears that this service was not fully tested by Microsoft AX development team, but they have posted a hot fix here:

  3. Nonton sabung ayam pisau Live dan Pasang Taruhan Kamu bersama BOLAVITA Bandar Taruhan Online Terpercaya !
    wechat : bolavita
    line : cs_bolavita
    WA : +6281377055002
    BBM: D8DB1C57