Forum Discussion

Hillcrest195's avatar
Hillcrest195
Copper Contributor
Jan 24, 2023

SPMT - Some Documents don't migrate with error "An item with the same key has already been added"

I am hoping someone can shed some light on what this issue is.

I am attempting to migrate documents from a list from a client's on-prem 2013 foundation server to SP online using SPMT.

The migration tools creates the folder structure for the inside the target list but won't migration any documents. The error is "An item with the same key has already been added" but none of the documents exist in the target list.

The full error is:

TimeStamp:23/01/2023 12:27:50 AM Package#:[2] EventType:[JOBERROR] PackageID:[5fcad3bd-7598-478c-8ab4-fc3d4a391cb6] JobID:[7aca046b-fc25-42af-82a5-a0c6177d06cb] FilesCreated:0/67
Event:JobError
JobId:7aca046b-fc25-42af-82a5-a0c6177d06cb
Time:01/23/2023 00:27:49.981
TotalRetryCount:0
MigrationType:None
MigrationDirection:Import
ObjectType:ListItem
Url:Users/Open/Users/XXXXXXXX/000002V01.XXXXXXXXX.docx
Id:5ada6623-4674-491c-a72e-c7a4dfed74b9
SourceListItemIntId:249
TargetListItemIntId:249
ErrorCode:-2147024809
ErrorType:System.ArgumentException
Message:An item with the same key has already been added. CallStack -- at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.SharePoint.Deployment.FileSerializer.GetMetaInfo(SerializationInfoHelper infoHelper, ImportObjectManager importObjectManager)
at Microsoft.SharePoint.Deployment.FileSerializer.CreateOrUpdateFile(Object fileOrListItem, SPLoggerObject loggerObject, SPWeb web, Guid id, SPResourcePath& filePath, Boolean fileExistsInDb, Boolean isFirstVersion, Nullable`1 isLastVersion, Boolean hasWebParts, SerializationInfoHelper infoHelper, SerializationInfoHelper infoHelperListitem, StreamingContext context)
at Microsoft.SharePoint.Deployment.FileSerializer.CreateOrUpdateFileAndAssocData(Object fileOrListItem, SPLoggerObject loggerObject, SPWeb web, Guid id, SPResourcePath& filePath, Boolean fileExistsInDb, Nullable`1 isLastVersion, SerializationInfoHelper infoHelper, SerializationInfoHelper infoHelperListitem, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.ListItemSerializer.AddOrUpdateDoclibItem(SerializationInfoHelper infoHelper, SPListItem& listItem, SPLoggerObject loggerObject, SPWeb web, Guid newId, SPResourcePath& listItemServerRelativePath, Boolean bIsPublish, Boolean exists, Boolean isLastVersion, StreamingContext context, ISurrogateSelector selector, LoggerStatistics stats)
at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
CorrelationId:2ee38ea0-e062-1000-f174-a9fae9cbb066

 

1 Reply

  • Hillcrest195's avatar
    Hillcrest195
    Copper Contributor
    After lodging this issue with MS via paid support and NOT getting an answer after8 days, I finally worked out the issue myself.

    Short Answer:
    The error occurs when a content type field is created by script that has its title property set to save value as one of the Title properties in the "Unknown Document Type". SPMT seems to match content fields on Title property (which in don't need to be unique) instead of or in additional to the Name property of a Content Type Field. In my case I have a field with a Name of "OurDocsTitle" with a Title of "Tile" that was clashing with the field Named "Title" which has a Title of "Title" from the Unknown Document Type. Renaming the Title of OurDocsTitle to something other than "Title" allowed the migrator to work.

    Some background:
    A content type field has two distinct properties Name and Title. Name must be unique within the site. It is the key used to address and reference the field in the content type. Title is the label shown on the list of documents when that property is exposed is a view and DOES NOT Need to be unique. The SharePoint UI only exposes one field for a name and title. When created via the UI the Name and Title are set to the same value. When you update a field via the UI it updates the title only and the Name remains unchanged.
    When creating a content type field via script, you have access to both the Name and Title property as separate properties.

    There is a "Special Content Type" Group which contains a single Content Type called the "Unknown Document Type" that SP seems to associate with all sites (and lists). This Content Type IS NOT included in the list of content types shown in the Site Columns list in Site Settings but IS included in the Site Content Types List. This content type included two fields with the name of Title and Name which have their Titles set to save values as the name.

    The migrator fails with the above error when the Title property of one of your custom content types matches the name/title of one of the "Unknown Document Type" fields. Ie "Name" or "Title"

Resources