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