Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

trying to save n:n data through plugin?

$
0
0

Hello - My system has a custom n:n relationship defined between case and contact.  I'm trying to add a new row to the n:n table through a plugin but I'm getting an error.  Here's a code snippet from the plugin:

            foreach (var c in contacts)
            {
                var caseFinder = new AssociateRequest
                {
                    Target = new EntityReference(new_case_finder.EntityLogicalName, parentId),
                    Relationship = new Relationship("new_CaseFinders"),
                    RelatedEntities = new EntityReferenceCollection
                    {
                        new EntityReference(Incident.EntityLogicalName, parentId),
                        new EntityReference(Contact.EntityLogicalName, c.Id)
                    }
                };
                service.Execute(caseFinder);
            }

In the code above:

* "new_case_finder" is the name of the n:n table in the CRM database
* "new_CaseFinders" is the name of the relationship for which the new_case_finder table exists

Here's the error I'm getting on execute:

"The entity relationship role with id c5bb6639-81be-e211-a28d-00155d760004 either doesn't exist in or is not an association entity in relationship with id c2bb6639-81be-e211-a28d-00155d760004"

Any idea what I might be doing wrong here?


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>