AX 2012 Metadata – issue with Maps

By Laura Lake | February 10, 2014

AX 2012 Metadata - corruption in model metadata

In AX 2012 Metadata, we have come across a scenario in which a model’s metadata becomes corrupted. The symptom presents as objects that suddenly won’t compile, throwing errors such as…

The map does not exist.

Operand types are not compatible with the operator.

AX 2012 Metadata

Upon investigation, code is found which seems to indicate that the referenced object does not exist.

public DimensionDefault parmDefaultDimension()

{

   return vendInvoiceMap.VendInvoiceMap::defaultDimension();

}

 AX 2012 Metadata - example of Map issue

In one specific case, we found that the vendInvoiceMap object did not exist as a Map. Instead, it was in the AOT as a Table, causing all of the objects referencing the Map to throw errors during compile.

It is not clear what causes the corruption in the metadata, since Microsoft has not been able to reproduce the issue. However, they have provided a sql script which will allow for updating the bad metadata from a database in which the metadata is not corrupted.

For the purpose of this example, the vendInvoiceMap object in the MicrosoftDynamicsAX_model database is the one we are trying to fix. We know that we have a good copy in MicrosoftDynamicsAXTest_model.

Note: Backup the model database in the environment where the corruption exists before executing the following script.

 

-- This Select checks for the existence of the affected object in the corrupted environment

SELECT m.ElementType, m.Name, m.AxId, md.LayerId, manifest.DisplayName, md.Properties as Metadata

               FROM MicrosoftDynamicsAX_model.[dbo].ModelElement AS m

               INNER JOIN MicrosoftDynamicsAX_model.[dbo].ModelElementData AS md

                              ON m.ElementHandle = md.ElementHandle

               INNER JOIN MicrosoftDynamicsAX_model.[dbo].ModelManifest AS manifest

                              ON md.ModelId = manifest.ModelId

                AND m.ElementType = 44 AND m.Name = 'vendInvoiceMap'

 

 

-- This Select checks for the existence of the affected object in the clean environment

 

SELECT m.ElementType, m.Name, m.AxId, md.LayerId, manifest.DisplayName, md.Properties as Metadata

               FROM MicrosoftDynamicsAXTest_model.[dbo].ModelElement AS m

               INNER JOIN MicrosoftDynamicsAXTest_model.[dbo].ModelElementData AS md

                              ON m.ElementHandle = md.ElementHandle

               INNER JOIN MicrosoftDynamicsAXTest_model.[dbo].ModelManifest AS manifest

                              ON md.ModelId = manifest.ModelId

                AND m.ElementType = 44 AND m.Name = 'vendInvoiceMap'

                

-- Replaces corrupted metadata from clean environment

 

Update md Set md.Properties = md_base.Properties

FROM MicrosoftDynamicsAX_model.[dbo].ModelElement AS m

               INNER JOIN MicrosoftDynamicsAX_model.[dbo].ModelElementData AS md

                              ON m.ElementHandle = md.ElementHandle

               INNER JOIN MicrosoftDynamicsAXTest_model.[dbo].ModelElement AS m_base

                              ON m.ElementType = m_base.ElementType AND m.Name = m_base.Name

               INNER JOIN MicrosoftDynamicsAXTest_model.[dbo].ModelElementData AS md_base

                              ON m_base.ElementHandle = md_base.ElementHandle

AND m_base.ElementType = 44 AND m_base.Name = 'vendInvoiceMap' AND md_base.LayerId = 0

After executing this script, restart the AOS so that the object changes are picked up. In the AOT, expand Maps and you should be able to locate vendInvoiceMap. If so, recompile all affected objects. They should now compile cleanly. AX 2012 Metadata


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!