Hi All,
I am trying to associate the N:N relationship (Self referential) records in plugin. Example: Accounts to Accounts.
I am getting an exception of "Entity role must be specified for reflexive relationship".
Here is my code:
AssociateRequest associateRequest = new AssociateRequest();
associateRequest.Target = new EntityReference("iba_bc", BCId);
associateRequest.RelatedEntities = new EntityReferenceCollection();
foreach (var item in AssociatedBC)
{
associateRequest.RelatedEntities.Add(new EntityReference("iba_bc", new Guid(item.NewBCId.ToString())));
}
if (associateRequest.RelatedEntities.Count > 0)
{
associateRequest.Relationship = new Relationship("iba_bc_iba_bc");
associateRequest.Relationship.PrimaryEntityRole = EntityRole.Referenced;
var associateResponse = service.Execute(associateRequest);
}
Need help on this.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay