Home
»
Microsoft Dynamics AX
»
Dynamics AX 2012 Data Import using Excel Add-in
»
Dynamics AX 2012 Excel Add-in – Issues and Solutions (Index was outside the bounds of the array)
Dynamics AX 2012 Excel Add-in – Issues and Solutions (Index was outside the bounds of the array)
About
About Dynamics AX 2012 Data Import using Excel Add-in
Dynamics AX 2012 Excel Add-in Data Import techniques and best practices
Options
RSS for posts
Related Posts
DAX 2012 issue while importing LedgerJournalName with Excel add-in
by
Ludmila Tudose
on
6 Mar 2013
Suggested Answer
Dynamics AX 2012 Excel Add-in - Customer transactions import
by
Alex Anikiiev
on
12 Feb 2012
0
comments
AIF error with service namespace
by
RamerC
on
26 Mar 2012
Not Answered
View More
Dynamics AX 2012 Excel Add-in – Issues and Solutions (Index was outside the bounds of the array)
Alex Anikiiev
24 May 2012 12:27 AM
Comments
0
Dynamics AX 2012 Excel Add-in –
Issues and Solutions (Index was outside the bounds of the array)
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
Inbound port
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.
Select Data
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
BudgetTransactionHeader
BudgetTransactionLine
Please note that
LedgerDimension
field has its own
Dimension
icon (not marked with
Red
asterisk), however
LedgerDimension
is also mandatory field in
BudgetTransactionLine
table
Publish
Event Viewer
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.
Exceptions form
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
Publish
This time import process is successful
Result
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
$core_v2_language.FormatString($core_v2_language.GetResource('Blog_PostQuestionAnswerView_CommentsCountFormatString'), $post.CommentCount)
Read the complete post at
ax2012exceldataimport.blogspot.com/.../dynamics-ax-2012-excel-add-in-issues_23.html
Dynamics AX 2012
,
Dynamics ERP
,
Data Migration
,
Data Conversion
,
Application Integration Framework
,
Excel
,
Data Import
,
Dynamics AX 2012 Excel Add-in
,
Problem
,
Resolution
,
Issue
,
Solution