Saturday, October 20, 2012

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

Microsoft Dynamics AX 2012
Excel Add-in – Questions and Answers (Defaulting 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 defaulting logic?
 
Answer: The way the system implements defaulting 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 (LedgerJournalTable) - Description and Sales order (SalesTable) - Pool business entities fields in Microsoft Dynamics AX 2012.
 
Details
 
LedgerJournalTable and SalesTable Tables in Microsoft Dynamics AX 2012 have corresponding AxLedgerJournalTable and AxSalesTable 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 Defaulting Logic in this investigation we'll take a closer look at setTableFields method where the assignment of default values for fields usually happens.  
 
General journal – Description
 
Rich Client
 
Out-of-the-box in Rich Client once you specify Journal name on General journal header Description is populated from Journal name automatically
 
 
This is triggered in modified method of Form Data Source
 
Forms\LedgerJournalTable\Data Sources\LedgerJournalTable\Fields\JournalName\Methods\modified
 
Here's how Description is defined for Journal name
 
 
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 defaulting logic from Form interactively. For example, when new record is created on Form Data source initValue method on respective Data source (and Table) will be executed, or when field value is modified on the Form the system will execute modified method on Data source field (and modifiedField method on Table).
 
Excel Add-in
 
If you explicitly provide the value of Description before publishing data in Excel Add-in the system will take this value into account. By other words explicitly provided value overrides default value from Journal name 
 
Before publishing
 
After publishing
 
What if I don't specify Description?
 
If you don't provide a value of Description before publishing data in Excel Add-in it will still be populated from Journal name. Please note that you will see populated value of Description in Excel Add-in only after successful publishing 
 
Before publishing
 
After publishing
 
In Microsoft Dynamics AX 2012 LedgerJournalTableType class represents Ledger journal business entity of different types. LedgerJournalTableType class is equipped with number of methods in order to populate default values for certain fields including Description (LedgerJournalTable.Name)
 
Field name
Method name
JournalNum
defaultJournalNum
Name
defaultName
NumberSequenceId
defaultNumberSequenceId
JournalType
defaultJournalType
PaymentGenerated_IT
defaultPaymentGenerated_IT
OffsetAccount
defaultOffsetAccount
PostedDateTime
defaultPostedDateTime
OffsetAccountType
defaultOffsetAccountType
GroupBlockId
defaultGroupBlockId
Dimension
defaultDimension
CurrencyCode
defaultCurrencyCode
FixedExchRate
defaultFixedExchRate
DetailSummaryPosting
defaultDetailSummaryPosting
DocumentNum
defaultDocumentNum
ExchRateSecondary
defaultExchRateSecondary
ExchRate
defaultExchRate
FixedOffsetAccount
defaultFixedOffsetAccount
RemoveLineAfterPosting
defaultRemoveLineAfterPosting
CurrentOperationsTax
defaultCurrentOperationsTax
LedgerJournalInclTax
defaultLedgerJournalInclTax
BankRemittanceType
defaultBankRemittanceType
CustVendNegInstProtestProcess
defaultCustVendNegInstProtestProcess
VoucherAllocatedAtPosting
defaultVoucherAllocatedAtPosting
LinesLimitBeforeDistribution
defaultLinesLimitBeforeDistribution
WorkflowApprovalStatus
defaultWorkflowApprovalStatus
 
Default value of Description is populated in defaultName method
 
Classes\LedgerJournalTableType\defaultName
 
Call Stack:
<![if !supportLists]>-          <![endif]>Classes\LedgerJournalTableType\defaultName
<![if !supportLists]>-          <![endif]>Classes\LedgerJournalTableType\defaultRow
<![if !supportLists]>-          <![endif]>Classes\AxLedgerJournalTable\defaultRow
<![if !supportLists]>-          <![endif]>Classes\AxLedgerJournalTable\setTableFields
<![if !supportLists]>-          <![endif]>Classes\AxInternalBase\doSave
<![if !supportLists]>-          <![endif]>Classes\AxInternalBase\save
<![if !supportLists]>-          <![endif]>…
 
Please note that there's also defaulting logic related to Description in insert method in LedgerJournalTable Table which covers other functional scenarios
 
Tables\LedgerJournalTable\Methods\insert
  
Sales order – Pool
 
Rich Client
 
Out-of-the-box in Rich Client once you create Sales order header on Create Sales order form the system will populate Sales Pool ID right away
 
 
Please note that Pool is populated based on Default Pool from Parameters even before particular Customer account is selected
 
 
This is triggered from Form Data source initValue method which will eventually call initValue method on SalesTableType class
 
Once Customer account is selected the system will populate Pool based on Customer settings
 
 
This is triggered from Form Data source modified method which will eventually call modifiedField method on SalesTableType class
 
 
Excel Add-in
 
If you explicitly provide the value of Pool before publishing data in Excel Add-in the system will take this value into account. By other words explicitly provided value overrides default value from Customer (or Parameters)
 
Before publishing
 
After publishing
 
What if I don't specify Pool?
 
If you don't provide a value of Pool before publishing data in Excel Add-in it will still be populated from Customer (or Parameters). Please note that you will see populated value of Pool in Excel Add-in only after successful publishing 
 
Before publishing
 
After publishing
 
In Microsoft Dynamics AX 2012 SalesTableType class represents Sales order business entity of different types. SalesTableType class is equipped with number of methods in order to set values for certain fields including Pool (SalesTable.SalesPoolId)
 
 
Call Stack:
<![if !supportLists]>-          <![endif]>Classes\AxSalesTable\setSalesPoolId
<![if !supportLists]>-          <![endif]>Classes\AxSalesTable\setTableFields
<![if !supportLists]>-          <![endif]>Classes\AxInternalBase\doSave
<![if !supportLists]>-          <![endif]>Classes\AxInternalBase\save
 
Please note that what was done in 2 steps in Rich Client (Default Pool populated from Parameters and then Pool populated from Customer) on Create Sales order form is executed as 1 step in Excel Add-in when the data is published 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, Defaulting 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 comment: