Showing posts with label Associating the Competitor to Product in CRM. Show all posts
Showing posts with label Associating the Competitor to Product in CRM. Show all posts

Saturday, 18 May 2013

Associating the Competitor to Product in CRM

We can associate the Competitor to the Product using the below code.

var xrm = new XrmServiceContext("Xrm");

Guid competitorId = new Guid();

EntityReferenceCollection relatedEntitiesCompetitor = new EntityReferenceCollection();

relatedEntitiesCompetitor.Add(new EntityReference(CompetitorProduct.EntityLogicalName, competitorId));

Relationship relationshipCompetitor = new Relationship("competitorproduct_association");

xrm.Associate("product", newProduct.Id, relationshipCompetitor, relatedEntitiesCompetitor);

Here the competitorproduct_association is the relationship between the Price List and the Product. We can see the relationship in the CRM portal. The steps are
Settings->Customizations->Customize the System->Entities->Select the Entity ->Click on Relationship.