
Dear Support Team,
I got a below error while creating service task in Dynamics 365
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Cannot insert duplicate key.Detail:
<OrganizationServiceFault xmlns:i="">www.w3.org/.../XMLSchema-instance" xmlns="">schemas.microsoft.com/.../Contracts">
<ActivityId>2d2084ee-44c7-49cb-86c4-a23cd9fe8d53</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="">schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">0</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Cannot insert duplicate key.</Message>
<Timestamp>2020-02-21T03:42:43.5271868Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>
[Infoman.Crm.ServiceTaskPlugins: Infoman.Crm.ServiceTaskPlugins.PartRequirements.RelationGeneratorPlugin]
[c6f984f0-c11a-e311-9008-00155d204602: Infoman.Crm.ServiceTaskPlugins.PartRequirements.RelationGeneratorPlugin: Create of cu_servicetask]
</TraceText>
Any one help me and provide solution for this?
Best Regards,
Punit
Hi Punit,
There are couple of reasons for this exception and this exception is getting generated from customer plugin, please help to review your plugin login or you can un-register that plugin step and create entity record. Please also help to confirm if you entity has auto number or not.
if your entity has auto number then you can check the seed value and the following document may help you:
if your entity don't have auto number you can verify if your entity has keys using Setting > Customize the system, under each entity we have keys option where we can define unique keys. Thank you.
Based on exception, it seems your plugin logic is creating problem while creating record. Please review the plugin logic and try above two options for auto number and unique keys for entity.
Best Regards,
Mobeen Mohsin