sparkymark75
sparkymark75

Reputation: 593

Error when importing an unmanaged solution

I'm trying to migrate some customizations from our development environment to the test environment. I have everything I need in a solution. When I import this into the test environment, it fails with the error;

An item with the same key has already been added.

In the error file that I download from the solution import screen, it's listed against the Form ItemType for the Incident entity. My solution contains a new custom form, it also has the definitions for the 2 default "Information" forms.

With verbose tracing, I can see the error in an xml string;

<formXml LocalizedName="Case" OriginalName="Case"
         Description="Service request case associated with a contract."
         id="Incident" processed="true">
    <result result="failure" errorcode="0x80044150"
            errortext="An item with the same key has already been added."
            datetime="09:52:28.65" datetimeticks="635049859486557248" />
</formXml>

this is within the entitySubhandlers node. However there's nothing to pinpoint exactly what the issue is. Any ideas? Thanks.

Upvotes: 1

Views: 7406

Answers (6)

link64
link64

Reputation: 1976

I had the same issue and it was caused by changing the type of an existing field.

The current system had a field called ecs_salutation of type Single Line of Text. The solution had deleted and readded this field as an Option Set

The import would fail because the field types didnt match. I had to manually remove the field from the forms, delete it from the entity and republish before being able to import the solution succesfully

Upvotes: 1

ichachan
ichachan

Reputation: 667

I encountered into this problem today when importing customization from dev into production. Turned out there is a custom field that was deleted in dev and then re-created using the same schema name, but different data type. I deleted that field in production and the customization import is successful.

Upvotes: 0

jef smets
jef smets

Reputation: 181

I ran into the same problem today and found a solution.

In CRM you have the display name, name and physical (database column) name. For some reason the physical name is sometimes generate with capitals and sometimes not.

My scenario: contact with field "Field 1" (display - name - physical) Dev environment: "Field 1" "new_field1" "new_Field1" Test environment: "Field 1" "newfield1" "new_field1" => note that there is no capital F here

The occured when I deleted the field on dev and recreated it. Previously the physicial name was "new_Field1" on dev, now it is "new_field1".

A suggested solution I found on the web is deleting the field and recreating it. That would obviously not work for me but it might work for you. See: https://community.dynamics.com/crm/b/crmpowerobjects/archive/2013/07/01/field-is-not-unique-error-when-importing-a-solution-in-crm-2011.aspx

My solution was to update the field directly in the database (you cannot do this if you have a CRM online environment, I'm using CRM 2011 on-premise Rollup 15, SQL server 2008 R2 SP1). You need to modify the table schema + the physical name of the record in the Metadataschema.Attributes. Do this at your own risk as this is not supported by MS and take a full backup.

Upvotes: 2

gideon
gideon

Reputation: 11

I got the same error while importing customisation to the Dev environment: An item with the same key has already been added on User entity.

I saw James Wood's answer and compared the User entities on boths side. And realised that I had 3 custom fields on both sides. These were created by a 3rd party solution separately on the live and Dev.

I just deleted the 3 custom fields in Dev environment. When I tried the import again, it worked perfectly.

Thanks James for the tip.

Upvotes: 1

sparkymark75
sparkymark75

Reputation: 593

I couldn't get around this. I documented my customisations, did a restore of our test environment (which is itself a restore of production) as a new development environment. Once I did this, everything worked as expected.

Upvotes: 0

James Wood
James Wood

Reputation: 17562

I believe this can occur when, you have a field in both environments (with the same schema name) but they are of different types.

Have you already customised the test environment? If so I would look to compare the custom fields on that entity.

Upvotes: 0

Related Questions