Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

Cannot insert duplicate key but not duplicate detection rule exists

Posted on by 56

I'm trying to merge an account record with another. After the merge-dialog an clicking on okay, I get the message that a record with same values already exists. I deactivated all duplicate detection rules but same issue. Also I checked if an alternate key exists on account. nope....

I checked the trace an got the following stacktrace: - what does the businessprocessflowinstance has to do with this?

Web Service Plug-in failed in SdkMessageProcessingStepId: {}; EntityName: businessprocessflowinstance; Stage: 30; MessageName: Update; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
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.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
Inner Exception: Microsoft.Crm.BusinessEntities.CrmDuplicateRecordException: Cannot insert duplicate key.
at Microsoft.Crm.Platform.Server.DataEngine.EntityCrudManager.ThrowDuplicateRecordException(IBusinessEntity entity, ExecutionContext context, SqlException e)
at Microsoft.Crm.Platform.Server.DataEngine.EntityCrudManager.<>c__DisplayClass5_0.<Update>b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action)
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.DoUpdate(IBusinessEntity entity, FilterExpression filter, ExecutionContext context)

[2022-10-06 10:23:32.607] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 65 |Category: Exception |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: |ActivityId: | CrmDuplicateRecordException..ctor ilOffset = 0x9
at CrmDuplicateRecordException..ctor(String message, Exception innerException, Int32 errorCode) ilOffset = 0x9
at RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) ilOffset = 0xFFFFFFFF
at RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ilOffset = 0xF4
at RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) ilOffset = 0x1C8
at Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) ilOffset = 0xAF
at Activator.CreateInstance(Type type, Object[] args) ilOffset = 0x0
at VersionedPluginProxyStepBase.WrapExceptionToThrow(CrmException exception, PipelineExecutionContext context) ilOffset = 0x56
at VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context) ilOffset = 0x7
at PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context) ilOffset = 0x83
at <>c__DisplayClass2_1.<Execute>b__0() ilOffset = 0x84
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at Pipeline.Execute(PipelineExecutionContext context) ilOffset = 0x127
at PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context) ilOffset = 0x32
at MessageProcessor.Execute(PipelineExecutionContext context) ilOffset = 0x237
at InternalMessageDispatcher.Execute(PipelineExecutionContext context) ilOffset = 0x104
at ExtensiblePlatformMessageDispatcher.Execute(PipelineExecutionContext pluginContext) ilOffset = 0x0
at ExtensiblePlatformMessageDispatcher.UpdateWithInvocationSource(BusinessEntity entity, FilterExpression filter, Int32 invocationSource, ExecutionContext context) ilOffset = 0x101
at ExtensiblePlatformMessageDispatcher.Update(BusinessEntity entity, FilterExpression filter, ExecutionContext context) ilOffset = 0xA
at <>c__DisplayClass187_0.<UpdateWithPipelineAndExtensions>b__0() ilOffset = 0xC1
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at <>c__DisplayClass178_0.<Update>b__0() ilOffset = 0x98
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at BpfBusinessEntityService.Update(IBusinessEntity entity, ExecutionContext context) ilOffset = 0x5B
at <>c__DisplayClass23_0.<CascadeMergeThroughOneToManyEntityRelationships>b__0() ilOffset = 0x2E3
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at <>c__DisplayClass22_0.<CascadeMerge>b__0() ilOffset = 0x65
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at BusinessProcessObject.Merge(BusinessEntityMoniker masterMoniker, Guid subordinateId, IBusinessEntity entity, Boolean bPerformParentingChecks, ExecutionContext context) ilOffset = 0x14D
at AccountService.Merge(BusinessEntityMoniker masterMoniker, Guid subordinateId, IBusinessEntity entity, Boolean performParentingChecks, ExecutionContext context) ilOffset = 0x25
at RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) ilOffset = 0xFFFFFFFF
at RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) ilOffset = 0x16
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) ilOffset = 0x6C
at LogicalMethodInfo.Invoke(Object target, Object[] values) ilOffset = 0x3F
at InternalOperationPlugin.Execute(IServiceProvider serviceProvider) ilOffset = 0x43
at V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context) ilOffset = 0x0
at VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context) ilOffset = 0x7
at PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context) ilOffset = 0x83
at <>c__DisplayClass2_1.<Execute>b__0() ilOffset = 0x84
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action) ilOffset = 0x49
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action) ilOffset = 0x12
at Pipeline.Execute(PipelineExecutionContext context) ilOffset = 0x127
at PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context) ilOffset = 0x32
at MessageProcessor.Execute(PipelineExecutionContext context) ilOffset = 0x237
at InternalMessageDispatcher.Execute(PipelineExecutionContext context) ilOffset = 0x104
at ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, Guid callerRegardingObjectId, Int32 invocationSource, Version endpointVersion, OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest) ilOffset = 0x33D
at OrganizationSdkServiceInternal.DispatchRequest(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest, SdkResponseDescription responseDescription, SdkPerformanceCounterContext sdkPerformanceCounterContext) ilOffset = 0x6
at OrganizationSdkServiceInternal.ExecuteRequestRequestWithInstrumentation(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest) ilOffset = 0xCD
at <>c__DisplayClass17_0.<ExecuteRequest>b__0() ilOffset = 0xAA
at ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Func`1 func) ilOffset = 0x43
at XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Func`1 func) ilOffset = 0x0
at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, UserAuth userAuth, Guid targetUserId, Guid targetCallerRegardingObjectId, UserType targetUserType, OrganizationContext context, Boolean returnResponse, Boolean checkAdminMode) ilOffset = 0x11E
at OrganizationSdkServiceInternal.ExecuteRequestInternal(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext) ilOffset = 0x7F
at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext) ilOffset = 0x60
at OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext) ilOffset = 0x1B
at InprocessServiceProxy.ExecuteCore(OrganizationRequest request) ilOffset = 0x20
at PlatformCommand.XrmExecuteInternal() ilOffset = 0xB5
at MergeRecordsHandler.Merge(String dataXml, Guid masterId, Guid subordinateId, Boolean update, Int32 parentingCheck, Int32 objectTypeCode) ilOffset = 0x98
at MergeRecordsHandler.ProcessRequestInternal(HttpRequest request) ilOffset = 0xE0
at AppHttpHandlerWithKeepAlive.ProcessRequestInternal(HttpContext context) ilOffset = 0x3D
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() ilOffset = 0x18D
at HttpApplication.ExecuteStepImpl(IExecutionStep step) ilOffset = 0x64
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) ilOffset = 0x15
at PipelineStepManager.ResumeSteps(Exception error) ilOffset = 0x27A
at HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) ilOffset = 0x31
at HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) ilOffset = 0xB0
at PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) ilOffset = 0x131
at PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) ilOffset = 0x0
at UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) ilOffset = 0xFFFFFFFF
at UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) ilOffset = 0xFFFFFFFF
at PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) ilOffset = 0x1E7
at PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) ilOffset = 0x0

thank you for any hint

©a-x-i

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    Hi,

    That's the question to Microsoft as it is internal to Microsoft product.

  • Axi Bachlechner Profile Picture
    Axi Bachlechner 56 on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    we solved the problem.

    the organisation where we had this problem was a migrated organization (from 8.1 to 9.0)

    After the migration one index of the entity BusinessProcessFlowInstanceBase was set to unique. If we set up a new organization with 9.0 this indes is non-unique. 

    Here the differences:

    new organization:

    image_5F00_2022_2D00_10_2D00_25_5F00_114931678.png

    migrated organzation:

    image_5F00_2022_2D00_10_2D00_25_5F00_115013107.png

    This caused the error. The question, which remains: why is this index set to unique during migration.

    ©a-x-i

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    Hi,

    Have you tried disabling any custom plugin/workflow/javascript?

  • Axi Bachlechner Profile Picture
    Axi Bachlechner 56 on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    I don't think it's a bug in Merge operation. I tested the same situation on a vanilla system. Created two accounts, started bpf and merged them. Everything okay.

    Additionally I found this post: community.dynamics.com/.../business-process-flow-javascript-issue with exactly same error. But unfortunately no response :(

    a-x-i

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    Hi,

    It seems to be a bug in Merge operation. Please open support ticket with Microsoft.

  • Axi Bachlechner Profile Picture
    Axi Bachlechner 56 on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    Still getting this error. 

    This error only comes if a business process flow exists on the account entity. No matter if it's finished or not.

    The detail I found in trace:

    Cannot insert duplicate key row in object 'dbo.BusinessProcessFlowInstanceBase' with unique index 'cndx_Entity1_ProcessId'. The duplicate key value is"

    I deactivated all workflows, and also disabled all plugins but the error still exists.

    So, I still need help.

    thank you

    ©a-x-i

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Moderator on at
    RE: Cannot insert duplicate key but not duplicate detection rule exists

    Hi Axi Bachlechner,

    Might be there are some plugins or workflow extensions. Did you check the key in the default solution?

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • RE: Cannot insert duplicate key but not duplicate detection rule exists

    Hi,

    Please check if the related entities have a duplicate detection related to one of your fields.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans