Saturday 18 May 2013

Running Multiple Web Application in Different Ports in Single Web Role

We can run multiple web applications in a single web role.
Select the web role in where you want to add the new web application in different port.
Add the new end point with the port 9000.
Now open the csdef file.
Under sites section of the web role add the below configuration.

<Site name="WebApp2" physicalDirectory="path to the web application">
<Bindings>
     <Binding name="Endpoint2" endpointName="Endpoint2"/>
</Bindings>
</Site>

If we add the project in solution we can add the relative path also. For example, if your ServiceConfiguration.csdef file is located at C:\projects\CloudProject\ServiceConfiguration.csdef and the folder containing your new web site is located in C:\projects\NewWebSite then the relative path in the physicalDirectory attribute would be "..\NewWebSite".

Associating the Sales Literature to Product in CRM

We can associate the Sales Literature to the Product using the below code.

var xrm = new XrmServiceContext("Xrm");

Guid salesLiteratureIdnew Guid();

EntityReferenceCollection relatedEntitiesSalesLiterature = new EntityReferenceCollection();
                           
relatedEntitiesSalesLiterature.Add(new EntityReference(CompetitorProduct.EntityLogicalName, salesLiteratureId));
                           
Relationship relationshipSalesLiterature = new Relationship("productsalesliterature_association");
                           
xrm.Associate("product", newProduct.Id, relationshipSalesLiterature, 
relatedEntitiesSalesLiterature);

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

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.

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.