DMF – Cannot create a record in Product number (EcoResProductIdentifier)

When working with the new Data migration framework module in Dynamics AX 2012 you will encounter a lot of problems and strange errors. One I recently encountered is this error message.

“Cannot create a record in Product number (EcoResProductIdentifier). The record already exists”


This seemed a weird one considering the products that I’m was trying to migrate didn’t exist in Dynamics AX.

First of all I need to mention that I got this error two times and because of different reasons.

The first reason for this error, in my case, was that a record already existed in the EcoResProductIdentifier table for a product not uncluded in my source file with the value in field Product set to 0. This field contains the reference to the RecId of the product, which means that in this case there is no product referenced. This tells me that something must have gone wrong with a previous copy to target process. I can only speculate but this seemed like the most likely culprit.

This was also not just a problem in the EcoResProductIdentifier table, but also the EcoResStorageDimensionGroupProduct and the EcoResTrackingDimensionGroupProduct table that also has a record each referencing the Product RecId 0.

There was also a record in the InventTable for the product in question, but no record in the table EcoResProduct.

I used this script to remove these records and get past this error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
static void FO_RemoveProductZero(Args _args)
{
    EcoResProductIdentifier             EcoResProductIdentifier;
    EcoResStorageDimensionGroupProduct  EcoResStorageDimensionGroupProduct;
    EcoResTrackingDimensionGroupProduct EcoResTrackingDimensionGroupProduct;
    InventTable                         inventTable;
 
    ttsBegin;
 
    while select EcoResProductIdentifier
        where EcoResProductIdentifier.Product == 0
    {
         delete_from EcoResStorageDimensionGroupProduct
            where EcoResStorageDimensionGroupProduct.Product == 0;
 
        delete_from EcoResTrackingDimensionGroupProduct
            where EcoResTrackingDimensionGroupProduct.Product == 0;
 
        delete_from EcoResTrackingDimensionGroupProduct
            where EcoResTrackingDimensionGroupProduct.Product == 0;
 
        delete_from inventTable
            where inventTable.ItemId == EcoResProductIdentifier.ProductNumber;
    }
 
    delete_from EcoResProductIdentifier
        where EcoResProductIdentifier.Product == 0;
 
    ttsCommit;
 
}

I tried the copy to target function again and still got the same problem. This time on one of the products I was trying to migrate. At this point the debugger was my only option and it was also the tool needed to find the solution.

As it turned out the reason for the error this time was that a very important value missing in the file I was trying to import, namely ProductSubType. This value is mandatory in the staging table for products, but no error was thrown during “Get staging data” process despite this missing value. The result of this missing value when doing copy to target is that no record is created in the table EcoResProduct. This is the reason that the value is set to 0 in the Product field in the table EcoResProductIdentifier. This works with the first record that is being created, but the next one gets the error since the table EcoResProductIdentifier has an index that doesn´t allow duplicates in field Product.

Now, the reason that my product wasn´t created properly might not be exactly the same as why you are experiencing this problem, but you have the same problem just the same. I think it´s safe to conclude that if I hadn´t gotten the error the second time I wouldn´t have gotten it the first time either. So the problem is that the Product is not created in the EcoResProduct table as it should be.

To find out if the reason this is happening to you, put a breakpoint in the insertUpdate method of the DMFProductEntityClass class. If the RecID of _target is 0 when it is returned then this is a good place for you to start. Because for some reason the EcoResProduct has not been created properly and you will not get an error message stating why.

As I said, you might not have this problem because of the same reason as I did, but I hope my experience, and the way I found the solution, might help you get past this error message once and for all.

This is for the BETA version of the Data migration framework. There is now a BETA 2 released. I don´t know if this problem is fixed in the new version.

Last 5 posts in Data Migration Framework

4 thoughts on “DMF – Cannot create a record in Product number (EcoResProductIdentifier)

  1. I had an similar Error with our Data Import with exactly the same error message.
    The reason that AX couldn’t create the ECOResProduct was the language which was used by the consultant and me as a developer. For Enum mappings it seems that AX is using something like str2enum.
    In our case we had an CSV file with english Namings for the ProductType. The ProductType in the CSV File was saved with “Product”. If AX is used with English languag everything works fine as AX can find the Enum Value for “Product”. If AX is used with as in our case with german language, AX cannot find the enum value.
    If the CSV file would used the german Name “Produkt” it would have worked. AX or better the funciton Str2Enum seems to search the EnumValue by the Label Value. The Label Value is dependent to the selected language.
    So it is important to use the same language in AX as is used for Enum values in the file which will be imported. Otherwise problems can occure if an enum is important.

  2. EcoResProductIdentifier issue:

    When we use DMF for ProductMaster entity, it’s not updateing EcoResProductIdentifier table. So when we release product to a company, it error out as ‘Field Item number must be filled in.’ -The release has been canceled.

    I created a job to fix this issue, here is the code:

    EcoResProductIdentifier ecoResProdIdentifier;
    EcoResProduct prod;
    ;

    while select prod notExists join ecoResProdIdentifier
    Where prod.recid == ecoResProdIdentifier.Product
    {
    prodIdentifier.Product = prod.RecId;
    prodIdentifier.ProductNumber = prod.DisplayProductNumber;
    ttsbegin;
    prodIdentifier.insert();
    ttscommit;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *