web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

"An item with the same key has already been added" error while publishing an entity

(0) ShareShare
ReportReport
Posted on by 58

We are in the process of upgrading our application from CRM 4.0 to CRM 2015 and currently in CRM 2013. While trying to publish the JavaScript changes for one of the main entity, we are receiving this error and the publish fails. We checked most of the posts regarding similar issue and tried out all the options. But nothing resolves the issue.

Since this is one of the main entity of the application, it has around 600 attributes and 100+ relationships. Recreating the entity would be difficult.

Service Pack 1 installation succeeded but the database updates failed. While trying to update the organization through Deployment Manager, the wizard throws the same error. Below is the stack trace from deployment manager.

09:20:45| Error| Installer Complete: OrganizationDatabaseHotFixer - Error encountered
09:20:45| Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationDatabaseHotFixer: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Crm.ObjectModel.StringMapPublisher.RetrieveExistingStringMaps(Int32 objectTypeCode, ICollection attributes, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.UpdateStringMaps(EntityMetadata entity, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.PublishStringMaps()
at Microsoft.Crm.ObjectModel.PublishXml.PublishDuringSetup(ExecutionContext context)
at Microsoft.Crm.SE.DllMethodActions.ImportSystemSolution.PublishStringStatusMapsRibbonData()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase)
at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters)
at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
InnerException:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Crm.ObjectModel.StringMapPublisher.RetrieveExistingStringMaps(Int32 objectTypeCode, ICollection attributes, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.UpdateStringMaps(EntityMetadata entity, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.PublishStringMaps()
at Microsoft.Crm.ObjectModel.PublishXml.PublishDuringSetup(ExecutionContext context)
at Microsoft.Crm.SE.DllMethodActions.ImportSystemSolution.PublishStringStatusMapsRibbonData()

09:20:45| Info| Setting organization state. New state = Failed
09:20:46| Error| Update Organization with Id=ed29ebf2-193a-e711-bcb4-005056b4365f failed with Exception:
System.Exception: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Crm.ObjectModel.StringMapPublisher.RetrieveExistingStringMaps(Int32 objectTypeCode, ICollection attributes, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.UpdateStringMaps(EntityMetadata entity, Int32 langId)
at Microsoft.Crm.ObjectModel.StringMapPublisher.PublishStringMaps()
at Microsoft.Crm.ObjectModel.PublishXml.PublishDuringSetup(ExecutionContext context)
at Microsoft.Crm.SE.DllMethodActions.ImportSystemSolution.PublishStringStatusMapsRibbonData()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase)
at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType)
at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters)
at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
--- End of inner exception stack trace ---

Any help would be greatly appreciated. Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Based on the stack trace, it appears that you have added the same value for more then one option for the optionset. As you are on CRM 2013, you can write some sql statements to identify if there are any duplicate values in the stringmap table.

    technicalreflections.wordpress.com/.../crm-2011-stringmap-table

    manojchauhan104.wordpress.com/.../stringmap-table-in-ms-crm

    Hope it helps.

  • surajcs55 Profile Picture
    58 on at

    Hi Ravi,

    Thanks for the quick turn around.

    There are no duplicate values in the StringMap table for any of the attributes. We checked the Javascript also for all the optionset transactions. The only operation we are performing is 'setValue' and 'removeOption'.

    Is there any way to figure out for which attribute this error occurs?

  • surajcs55 Profile Picture
    58 on at

    Anybody has any suggestions/answers for this issue?

  • Sreevalli Profile Picture
    3,256 on at

    Hi,

    As it is a main entity, try to check if there are any auto number fields like Quote Number,Case number etc. by default system will prevent pushing same value into these fields.

    -Sreevalli

  • surajcs55 Profile Picture
    58 on at

    No Sreevalli. There is an entity which gets auto incremented. That one is working fine currently. No issues there.

  • Sreevalli Profile Picture
    3,256 on at

    Since the issue with javascript changes, try removing the suspected functions and keep trying to publish. once we get the function which causing issue, then it will be more easy to spotout the field.

    I know its heard for the key entities with lots for customization but I couldnt see any other way

  • surajcs55 Profile Picture
    58 on at

    I commented the entire JavaScript code and tried publishing the entity. Still the error remains :(

    Any idea why?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    I am pretty sure it is not related to your JavaScript as it is coming from server while performing changes(insterting new record) to stringmap.

    You mentioned in your post that you are currently on CRM 2013. Can you check if you asyn service is running? There was a bug which fixed in update 2.0 with the same error message-

    support.microsoft.com/.../update-rollup-2-for-microsoft-dynamics-crm-2013-service-pack-1

    This is not directly related to your issue but it is possible that it is a bug in the current version of your CRM 2013 which is fixed in later updates. I would suggest to download/apply the latest update for CRM 2013 and then try again.

    Hope this helps.

  • surajcs55 Profile Picture
    58 on at

    Hi Ravi,

    The async service is up and running. We had installed all the updates for 2013. However for all the updates, we are getting a error "The Update Rollup 2 for Microsoft Dynamics CRM Server Service Pack 1 (KB2963850) completed successfully. However, the database update failed for some organizations".

    The same error "item with same key" is thrown in all the log files for the updates.

    Anything that can be done from the database side? Please advise.

    1513.CRM.jpg

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Okay, this confirm that it is related to your version. If you go to deployment manager, do you updates available for the organization. If yes, can you click and see if you can update the database. Its been long I logged into CRM server but I guess the option si somewhere on the right side to update.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans