Hi,
I am trying to associate Account with entity B with N:N relationship in code shown below.
AssociateEntitiesRequest req = new AssociateEntitiesRequest();
req.Moniker1 = new EntityReference { Id = moniker1.Id, LogicalName = moniker1.LogicalName };
req.Moniker2 = new EntityReference { Id = moniker2.Id, LogicalName = moniker2.Name };
req.RelationshipName = strEntityRelationshipName;
service.Execute(req);
tracingService.Trace(string.Format("After AssociateManyToManyEntityRecords"));
return true;
But it is giving me message:-
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.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">
<ErrorCode>-2147220937</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>Cannot insert duplicate key.</Message>
<Timestamp>2018-02-17T09:51:07.251855Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[Asociate Women Council: Asociate_Women_Council.Class1]
[f56fea6f-3212-e811-9431-00155d12a139: Asociate_Women_Council.Class1: Update of account]
</TraceText>
</OrganizationServiceFault>
Thanks
Prashant Verma
*This post is locked for comments
I have the same question (0)