Friday, 13 July 2012

OData error and office add-in

Recently I was trying to use OData for one of our user requirements. I was following the post from Robin. Every thing was smooth until the moment I tried the URL to return the OData Query Service definition

http://aoshost:8101/DynamicsAx/Services/ODataQueryService/


Following error appeared
The server encountered an error processing the request. The exception message is 'Exception of type 'Microsoft.Dynamics.AX.Framework.Services.Metadata.Exceptions.MetadataItemException`1[Microsoft.Dynamics.AX.Framework.Services.Metadata.Contracts.FieldGroupMetadata]' was thrown.'. See server logs for more details. The exception stack trace is:
at Microsoft.Dynamics.AX.Framework.Services.ODataQueryService.ODataMetadataCache.get_Metadata() at Microsoft.Dynamics.AX.Framework.Services.ODataQueryService.ODataService`1.GetService(Type serviceType) at System.Data.Services.WebUtil.GetService[T](Object target) at System.Data.Services.DataService`1.CreateProvider() at System.Data.Services.DataService`1.HandleRequest() at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
As the error states there is an issue with the field group metadata, but this does not explain what the error is, which table in the query has this error or how to resolve it. One of the tables in the query was CustTable and we have some modifications on this table. I then tried to read data from this table in Excel using office add-in and it threw the following error


Excel add-in was right on the spot in finding out the error that a field present in the field group does not actually exist in the table fields and the reference in field group was invalid (it was a custom field that during the upgrade was removed from the table but the was still present in the field group). Once that field was removed from the field group OData service was fine. Now what I really wonder is why one part of the application gives you meaningful error and not the other?


This posting is provided "AS IS" with no warranties. Use code at your own risk.

Wednesday, 11 July 2012

Too many forms open error

Today I imported a report from AX2009 to AX2012. Its a X++ report for customer ageing. The report required a few tweaks and it worked fine afterwards. However once I closed the report after printing it to the screen I got a strange error message when I clicked on any of the forms in client. The error message is


There were no other forms open as suggested by the message. The only way to get rid of it was to close the client and open it again.

This posting is provided "AS IS" with no warranties. Use code at your own risk.

Friday, 22 June 2012

Index with included columns

Dynamics AX 2012 now supports included columns on the indexes. While this is a great feature, there is a bug when there are indexes in system which has any of the included columns. The bug causes these indexes to be recreated in a full database synchronization even if no change is made to them. If these indexes exist on one of the larger tables, system takes a lot of time just to do a synchronization . Luckily a hot fix has been issued and can be obtained from customer source/partner source.

This posting is provided "AS IS" with no warranties. Use code at your own risk.

Friday, 15 June 2012

Attaching Ax32Server.exe process to Visual Studio

Last week I needed to debug a batch job. In AX2012 all the batch jobs run in IL. To debug these jobs you need to use Visual Studio and attach the AOS process. When I tried to attach Ax32Serve.exe, the process was disabled in the window as show below

Attach to process window
This made me wonder what is stopping the process from being available to attach. After a little investigation I realized that we are using Debug Diagnostic tool to create the dumps in case the AOS crashes and one of the crash rules to monitor the AOS was active. After de-activating the rule the AOS process was available to be attached for debugging purpose. So apparently only one application can monitor a running process.


This posting is provided "AS IS" with no warranties. Use code at your own risk.

Wednesday, 13 June 2012

Wrong EDT on HcmEmployment

In Dynamics AX 2012, financial dimensions has been given a full makeover. As a results the tables which had fields with EDT Dimension has to be replaced with fields that have the new EDT DimensionDefaut. This can be observed by looking at fields like CustTable.DefaultDimension. However HcmEmployment.DefaultDimension refers to EDT RefRecId as shown below.


Although it works fine as DimensionDefault is derived from RefRecId, but if you try to use some of the classes like DimensionProvider, system will throw following error 

Unknown type: RefRecId

The method addDataSourceToQuery in the DimensionProvider class checks the field's EDT and throws error if it is not a proper EDT. This field in the HcmEmployment table needs to be changed to the right EDT  until a hotfix addresses the issue.


This posting is provided "AS IS" with no warranties. Use code at your own risk.