Reviewed Book: Microsoft Dynamics CRM 2011 Application Design


Hi,

Last year I got an opportunity to review the “Microsoft Dynamics CRM 2011 Application Design” book http://bit.ly/135Wi8J
written by Mahendar Pal (Packt Publishing). Mahendar is Most Valuable Professional (MVP) for Microsoft Dynamics CRM. He is a good friend of mine and we stay in touch with each other and mostly discuss things around CRM. The review process was roughly around 6 months.

Now about the book, I found it to be quite unique in regards that it talks about the design and implementation aspect of Microsoft Dynamics CRM 2011. There are other good books available in the market on Microsoft Dynamics CRM, but they mostly talk about and explains the features available within the product. This makes the book helpful to both readers who are new to CRM as well as experienced.

There are total 8 chapters in the book in which readers will learn the basics of CRM 2011 and will also learn how to implement and create applications like Project Training Enrolment System, Employee Recruitment Management System, Hotel Management System etc. using CRM 2011. The readers will also get to learn how to create Silverlight applications, ASP.NET pages which integrates with CRM 2011.

Reading books is my hobby so was happy to get early access to the chapters for reading and reviewing and thanks to Mahendar and Packt Publishing for giving me this opportunity.

Lastly and most importantly I would also like to thank my friend and colleague Hina Mehta who helped me during the review process. She is an expert in CRM and CCA (which is an integral part of CRM now and there are very few people who have expertise on it). So her opinion and suggestions mattered a lot. You can subscribe to her blog here http://hinamehta14.wordpress.com/

All said and done,

Order a copy for yourself

http://www.packtpub.com/microsoft-dynamics-crm-2011-application-design/book

Bye.

“The Business Data Connectivity Metadata Store is currently unavailable” error in SharePoint Designer 2013 Preview


Hi,

I recently wrote a WCF service as a wrapper over CRM 2011 online and hosted it in Azure. The intent was to use this WCF service as BCS connection to integrate CRM 2011 online with SharePonit 2013 online. I tested the service with WCF Test Client and it was working fine.

The next step was to create an External Content Type in SharePoint Designer 2013. On selecting the External Content Types link inside SharePoint designer I kept getting the below error.

Next I used SharePoint Designer 2010 to connect to the SharePoint 2013 online site. There it didn’t throw the Metadata Store is currently available error.

However I kept getting the following error while trying to create a new external content type.

The workaround was to connect to SharePoint 2010 online site through SharePoint Designer 2010 and then generating the BCS Model from therein using our Azure Hosted WCF Service.

Hope it helps.

 

Using RetrieveMetadataChangesRequest class (Metadata Querying) in Polaris (CRM 2011)


Hi,

Let us take a very simple example to understand RetrieveMetadataChangesRequest class introduced in Polaris.

In this example we will retrieve information about all the attributes for contact entity where attribute type is of lookup.

For this we will use the RetrieveMetadataChangesRequest class.

This class contains the data which specifies the metadata information that needs to be retrieved.

RetrieveMetadataChangesRequest class has a Query property that accepts an EntityQueryExpression.

RetrieveMetadataChangesRequest retrieveMetadataChangesRequest = new
RetrieveMetadataChangesRequest()
{
Query = entityQueryExpression
};

EntityQueryExpression class defines the query to retrieve the metadata information.

Here we will need to set the following three properties of the EntityQueryExpression class


EntityQueryExpression entityQueryExpression = new
EntityQueryExpression()
{
Criteria = EntityFilter,
Properties = EntityProperties,
AttributeQuery = new
AttributeQueryExpression()
{
Criteria = AttributeFilter,
Properties = AttributeProperties
}
};
  • Criteria – specifies the filter criteria like for which entities we want metadata information to be retrieved.
  • Properties –
    specifies the properties to be returned.
  • AttributeQuery – specifies the criteria and properties for the entities attribute metadata like which type of attribute to retrieve and what all information to be retrieved for that attribute.

Specfying EntityFilter

This is how we will specify that we need metadata information for only the contact entity.

Specifying Properties of the Entity to be retrieved

Here we are specifying all the properties to be returned

MetadataPropertiesExpression EntityProperties = new
MetadataPropertiesExpression() { AllProperties = true };


Here we can set the AllProperties as false and instead specify the property names that we want to retrieve as shown below

EntityProperties.PropertyNames.Add(“AttributeType”);

Specifying the lookup attribute to be retrieved

MetadataConditionExpression metadataconditionexpressionEntity = new
MetadataConditionExpression();
metadataconditionexpressionEntity.PropertyName = "SchemaName";
metadataconditionexpressionEntity.Value = "Contact";
metadataconditionexpressionEntity.ConditionOperator = MetadataConditionOperator.Equals;
MetadataFilterExpression EntityFilter = new MetadataFilterExpression(LogicalOperator.And);
EntityFilter.Conditions.Add(metadataconditionexpressionEntity);

Specifying the properties to be retrieved for the lookup attribute

Here we are specifying that we only need the AttributeType and Description information for the Lookup attributes retrieved.

MetadataPropertiesExpression AttributeProperties = new
MetadataPropertiesExpression() { AllProperties = false };
AttributeProperties.PropertyNames.Add("AttributeType");
AttributeProperties.PropertyNames.Add("Description");

Full sample code

// specifying EntityFilter to only include entity having SchemaName as contact

MetadataConditionExpression metadataconditionexpressionEntity = new
MetadataConditionExpression();
metadataconditionexpressionEntity.PropertyName = "SchemaName";
metadataconditionexpressionEntity.Value = "Contact";
metadataconditionexpressionEntity.ConditionOperator = MetadataConditionOperator.Equals;
MetadataFilterExpression EntityFilter = new MetadataFilterExpression(LogicalOperator.And);
EntityFilter.Conditions.Add(metadataconditionexpressionEntity);

// specfying EntityProperties to include the properties to be retrieved
MetadataPropertiesExpression EntityProperties = new
MetadataPropertiesExpression() { AllProperties = true };
MetadataConditionExpression metadataExpression = new
MetadataConditionExpression("AttributeType", MetadataConditionOperator.Equals, AttributeTypeCode.Lookup);
MetadataFilterExpression AttributeFilter = new
MetadataFilterExpression(LogicalOperator.And);
AttributeFilter.Conditions.Add(metadataExpression);

//A Properties expression to limit the properties to be included with attributes
MetadataPropertiesExpression AttributeProperties = new
MetadataPropertiesExpression() { AllProperties = false };
AttributeProperties.PropertyNames.Add("AttributeType");
AttributeProperties.PropertyNames.Add("Description");

//An entity query expression to combine the filter expressions and property expressions for the query.
EntityQueryExpression entityQueryExpression = new
EntityQueryExpression()
{
Criteria = EntityFilter,
Properties = EntityProperties,
AttributeQuery = new
AttributeQueryExpression()
{
Criteria = AttributeFilter,
Properties = AttributeProperties
}
};

RetrieveMetadataChangesRequest retrieveMetadataChangesRequest = new
RetrieveMetadataChangesRequest()
{
Query = entityQueryExpression
};
RetrieveMetadataChangesResponse retrieveMetadataChangesResponse = (RetrieveMetadataChangesResponse)_service.Execute(retrieveMetadataChangesRequest);
EntityMetadata entityMetadata = retrieveMetadataChangesResponse.EntityMetadata[0];
foreach (AttributeMetadata attMetadata in entityMetadata.Attributes)
{
MessageBox.Show(attMetadata.Description.UserLocalizedLabel.Label);
}

Hope it helps.

ExecuteMultipleRequest message in Polaris (CRM 2011)


Using ExecuteMultipleRequest class we can now execute one or more message requests as a single batch.

For example in the code below we are creating 3 contact entity record as well as deleting one of the contact records as a single batch.

Here below, we are first initializing 3 contact entity record, then creating the associated CreateRequest and DeleteRequest.

We are then adding all these requests to OrganizationRequestCollection which we then use for the Requests property of the ExecuteMutlipleRequest class. The request are executed in the order in which they are added to the OrganizationRequestCollection.

Settings Property defines whether execution should continue if an error occurs and if responses for each message request processed are to be returned or not.

// Create 3 contact entitiy's record
Entity entity1 = new Entity("contact");
entity1.Attributes["lastname"] = "lastname1";
Entity entity2 = new Entity("contact");
entity2.Attributes["lastname"] = "lastname2";
Entity entity3 = new Entity("contact");
entity3.Attributes["lastname"] = "lastname3";
// Create CreateRequest and Delete Request
CreateRequest createReq1 = new CreateRequest();
createReq1.Target = entity1;
CreateRequest createReq2 = new CreateRequest();
createReq2.Target = entity2;

// DeleteRequest with incorrect guid to throw error

DeleteRequest deleteReq = new DeleteRequest();
deleteReq.Target = new EntityReference("contact", Guid.NewGuid());

CreateRequest createReq3 = new CreateRequest();
createReq3.Target = entity3;

// Initialize OrganizationRequestCollection

OrganizationRequestCollection orgReqCollection = new OrganizationRequestCollection();
orgReqCollection.Add(createReq1);
orgReqCollection.Add(createReq2);
orgReqCollection.Add(deleteReq);
orgReqCollection.Add(createReq3);

// Intialize ExecuteMultipleRequest

ExecuteMultipleRequest executeMutlipleRequest = new ExecuteMultipleRequest();
executeMutlipleRequest.Requests = orgReqCollection;
executeMutlipleRequest.Settings = new ExecuteMultipleSettings();

// ContinueOnError - specifies whether to continue in case of error in any of the request or not
executeMutlipleRequest.Settings.ContinueOnError = false;

// ReturnResponses - specifies whether to return responses for the requests or not
executeMutlipleRequest.Settings.ReturnResponses = true;

ExecuteMultipleResponse executeMulResponse = (ExecuteMultipleResponse) _service.Execute(executeMutlipleRequest);

In the above example we are deliberately throwing exception for the DeleteRequest.

So if we are setting the ContinueOnError property as false, our program will create the first two contact record and then throws exception.

Contact Records Created:

Exception:

And if we are setting the ContinueOnError as true, our program will create all the three contact records and for the DeleteRequest it will return the error message as a part of response as we have set the ReturnResponses as true.

All the three contact records created:

ExecuteMultipleResponse:

Here we get 4 responses one for each of the requests in OrganizationCollectionRequest.

IsFaulted property of the ExecuteMultipleResponse has value as true as we get a FaultException in case of DeleteRequest.

The Message for the DeleteRequest gives us the error message.

The response for the CreateRequest contains the Guid of the contact record created.


Hope it helps

“Network Error” while calling WCF Service through JavaScript.


Hi,

I was getting the following “Network Error” on calling WCF Service using XMLHttpRequest within an html page through JavaScript.

I was using IE 10 in a Windows 8 machine.

After some searching found out that this is a known issue.

http://bugs.jquery.com/ticket/12790

Running the same in compatibility mode worked properly.

Hope it helps.

Simple integration between CRM 2011 online and SharePoint 2013 online.


Hi,

I was recently working on a POC that required us to show a kind of integration between CRM 2011 online and SharePoint 2013 online. Basically here based on the case record opened in CRM we wanted to show associated information in the SharePoint 2013 website (could be wiki page, documents, web page etc.) within an iframe of the Case form.

So we first created an Office 365 Preview account for SharePoint 2013.

http://www.microsoft.com/office/preview/en/office-365-enterprise

Added few documents to it and created a custom search result page.

Here the nice thing about SharePoint 2013 is the Document Preview feature. Hover over the search results and user will be able to see the preview of the same.

Here the search term is passed in the query parameter k

https://xxx.sharepoint.com/search/Pages/results.aspx?k=product1

So we simply had to use the same URL in the IFrame inside CRM and in the onload, change the url to add our own value for k query parameter to show respective search results within CRM’s form IFrame.

We already had a CRM 2011 online (trial) instance created in Office 365 online, unfortunately it had SharePoint 2010 online in it and here we specifically wanted to showcase the Document Preview feature which is not in SharePoint 2010.

The issue here was that both CRM 2011 online and SharePoint 2013 online were part of different Office 365 instance. So if we are showing the SharePoint 2013 page within CRM 2010 online it would give the “user not authorized” access.

The solution to this was to give the CRM 2011 online user access to the SharePoint 2013 site.

For this we need to follow the below steps

Select the Sharing option for the selected site collection in the SharePoint administration page

Then

Open the site collection à site settings

Select People and Groups

Add the new user (added the email id of the CRM 2011 online user)

An invitation will be sent to the user’s mail box

CRM 2011 online user can now accept this invitation by logging in with his account. And he would have access to the SharePoint 2013 online site based on the Groups he has added by SharePoint admin. Now the Search Results page of SharePoint 2013 online can be shown inside CRM 2011 without any authentication issue as the user is now member of SharePoint site.

Hope this helps!

Similar Posts

https://nishantrana.wordpress.com/2013/06/13/import-user-profile-properties-in-sharepoint-2013-from-crm-2011-using-bcs/

https://nishantrana.wordpress.com/2013/06/13/integrating-crm-2011-and-sharepoint-2013-using-bcs-wcf-service-crud-operation/

https://nishantrana.wordpress.com/2013/05/04/integrating-crm-2011-online-and-sharepoint-2013-online-using-bcs-odata-proxy/