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: 'Index was outside the bounds of the array'.
Reason: This issue occurs because some mandatory fields are not specified for particular business entity. As the result validation of request XML will fail and exception will be thrown in Classes\AifWcfInterceptor\AfterReceiveRequest (CIL: AifWcfInterceptor.AfterReceiveRequest.xpp). However this exception will not be handled properly in external calling code (Dynamics AX 2012 Excel Add-in) and instead of meaningful "Invalid document schema" error message the user will see misleading "Index was outside the bounds of the array" error message. Please note that you can see the real error message in Event Viewer and/or Exceptions form assuming that Logging is enabled for appropriate Inbound port. In this example I will focus on Budget entries import using Budget Transactions Service AIF Web Service.
Dynamics AX Error
Solution: Please specify all mandatory fields for particular business entity you are trying to import before you Publish. In this example initially I didn't specify LedgerDimension field on BudgetTransactionLine table that is a part of Budget Transactions Service AIF Web Service data set which caused 'Index was outside the bounds of the array' error. After I properly specified all mandatory fields on business entities being imported the import process is successful.
Document data sources
Please note that BudgetTransactionsService AIF Web Service is activated as Document data source
Please note that Logging mode is 'All document versions' which is required for troubleshooting. Also it's important to mention that BudgetTransactionsService AIF Web Service operations (create, update, delete, read, etc) were exposed through OfficeAddins Enhanced Inbound port which was successfully activated. Alternatively you can activate BudgetServices Services Group which also contains BudgetTransactionsService AIF Web Service.
Data (Header – left and Line – right)
Please note that I specified the very minimum number of fields for BudgetTransactionHeader and BudgerTransactionLine tables looking at Red asterisk icon (Mandatory field) or Yellow Key icon (Foreign Key) next to the respective field in the Field Chooser
Please note that LedgerDimension field has its own Dimension icon (not marked with Red asterisk), however LedgerDimension is also mandatory field in BudgetTransactionLine table
If you take a look at error message logged in Event Viewer you will see the following error message "Object Server 01: An error has occurred in the services framework. Method: AifMessageInspector::AfterReceiveRequest. Error: System.ServiceModel.FaultException`1[Microsoft.Dynamics.Ax.Services.AifFault]: Invalid document schema. The following error was returned: The element 'BudgetTransLine' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction' has invalid child element 'Price' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction'. List of possible elements expected: 'LedgerDimension' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction'. (Fault Detail is equal to Microsoft.Dynamics.Ax.Services.AifFault)" which describes the real issue with document schema.
Same thing can be seen in Exceptions form in Dynamics AX 2012 which shows the same error message 'Invalid document schema. The following error was returned: The element 'BudgetTransLine' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction' has invalid child element 'Price' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction'. List of possible elements expected: 'LedgerDimension' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/BudgetTransaction'' as well as request XML message in History form in Dynamics AX 2012
To resolve this issue I'll specify LedgerDimension field for Budget entry line
I also specified more fields for Budget entry header and line for informational purposes
This time import process is successful
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