Showing posts with label Associating the Default Price List to Product in CRM. Show all posts
Showing posts with label Associating the Default Price List to Product in CRM. Show all posts

Saturday, 18 May 2013

Associating the Default Price List to Product in CRM

We can associate the Default Price List to the Product using the below code.

var xrm = new XrmServiceContext("Xrm");

Guid priceLevelId = new Guid();

EntityReferenceCollection relatedEntities = new EntityReferenceCollection();

relatedEntities.Add(new EntityReference(PriceLevel.EntityLogicalName, priceLevelId));

Relationship relationship = new Relationship("price_level_products");

xrm.Associate("product", newProduct.Id, relationship, relatedEntities);

Here the price_level_products 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.