Cleared MB2-701: Extending Microsoft Dynamics CRM 2013.


Hi,

Yesterday I cleared the Extending exam.

It had 48 questions with 700 as passing score.

I had referred the official training material of CRM 2011 as the training material for CRM 2013 are not released yet. Apart from that I had gone through different articles and videos to prepare for it.

There were very few questions that were specific to CRM 2013. Mostly they were around new methods added in Client SDK.

For someone who has a good hands-on experience in development in CRM 2011, passing this exam would not be that difficult.

Bye.

405 error – Method not allowed error while calling WCF service inside Plugin in CRM 2011.


Hi,

Recenlty we wrote a plugin that was calling a WCF Rest Service. The plugin was registered on Pre Create of an entity. Here if we were creating the entity record through web interface, the plugin was running fine.

However if we had that plugin being triggered by another plugin (the other plugin was creating the entity record triggering this particular plugin) we were getting “405 – method not allowed” error.

As it turned out the WCF service was getting confused regarding the operation context when being called by another plugin.

Specifying the OperationContextScope fixed the issue.

Original Code

</pre>
using (
 var webChannelFactory =
 new WebChannelFactory<IAutoNumber>(
 new Uri(dictionaryConfigSettings[Constants.AutoNumberServiceUrl])))
 {
 IAutoNumber referralOffer = webChannelFactory.CreateChannel();

// get the next number from sequence
 autoNumber = Constants.PrefixReferralOfferNumber +
 AddPadding(
 referralOffer.GetNextNumber(Constants.EntityNameReferralOffer),
 Constants.PrefixReferralOfferNumberLength);
 }
<pre>

The modified code

</pre>
using (
 var webChannelFactory =
 new WebChannelFactory<IAutoNumber>(
 new Uri(dictionaryConfigSettings[Constants.AutoNumberServiceUrl])))
 {
 IAutoNumber referralOffer = webChannelFactory.CreateChannel();

using (new OperationContextScope((IContextChannel)referralOffer))
 {
 // get the next number from sequence
 autoNumber = Constants.PrefixReferralOfferNumber +
 AddPadding(
 referralOffer.GetNextNumber(Constants.EntityNameReferralOffer),
 Constants.PrefixReferralOfferNumberLength);
 }

}
<pre>

The helpful post

http://www.rgoarchitects.com/nblog/CommentView,guid,26d9b30e-c441-4776-9778-4dfdab58bd3d.aspx

Hope it helps.

Unit Test RetrieveResponse in CRM using Microsoft Fakes.


Hi,

Recently we wrote a plugin that was using RetrieveResponse class to get the information of an n – n relationship using Relationship class.

The issue that we faced over here is that the Entity property of RetrieveResponse is read only, we cannot set it. The option was to write the wrapper class over it and use the same wrapper class in the code and the unit test.

/// <summary>
 /// Wrapper class for retrieve response
 /// </summary>
 [DataContract(Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
 public class RetrieveResponseWrapper : OrganizationResponse
 {
 /// <summary>
 /// The _entity
 /// </summary>
 private Entity entity;

/// <summary>
 /// Initializes a new instance of the <see cref="RetrieveResponseWrapper"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 public RetrieveResponseWrapper(OrganizationResponse response)
 {
 try
 {
 this.entity = ((RetrieveResponseWrapper)response).Entity;
 }
 catch
 {
 this.entity = ((RetrieveResponse)response).Entity;
 }
 }

/// <summary>
 /// Gets or sets the entity.
 /// </summary>
 /// <value>
 /// The entity.
 /// </value>
 public Entity Entity
 {
 get
 {
 return this.entity;
 }

set
 {
 this.entity = value;
 }
 }
 }

 

Check out this post for more details
http://www.alexanderdevelopment.net/post/2013/01/13/How-to-unit-test-C-Dynamics-CRM-interface-code-part-III

 Hope it helps.

Using Relationship and RelationshipQueryCollection class to retrieve n to n relationship details in CRM.


Suppose we need to query a n:n relationship and get details of both the entity records involved.

For this we can make use of Relationship and RelationshipQueryCollection class,

Suppose I have an entity named A  and it has n to n relationship with B  Entity.

This I how we can get the details all the A records associated with a particular entity B record.

i.e. Name of all the A records associated with a particular B entity record along with the  name of the B entity record.

</pre>
private void GetManytoManyRelationShipDetails(IOrganizationService _service, Guid entityBGuid)
 {
 // get offences records' name
 QueryExpression query = new QueryExpression("EntityA");
 ColumnSet cols = new ColumnSet();
 cols.AddColumn("EntityANameToBeRetreived");
 query.ColumnSet = cols;

// Relationship Name
 Relationship relationship = new Relationship("EntityA_EntityBRelationshipName");
 RelationshipQueryCollection relationshipColl = new RelationshipQueryCollection();
 relationshipColl.Add(relationship, query);

// get the legal issue record's name
 RetrieveRequest request = new RetrieveRequest();
 request.RelatedEntitiesQuery = relationshipColl;
 request.Target = new EntityReference("EntityB", entityBGuid);
 request.ColumnSet = new ColumnSet("EntityBNameToBeRetreived");
 RetrieveResponse response = (RetrieveResponse)_service.Execute(request);

string entityAName = string.Empty;

foreach (Entity entity in response.Entity.RelatedEntities[relationship].Entities)
 {
 entityAName += entity.Attributes["EntityAName"].ToString();
 }
 }

Hope it helps.

Fixed – Grid can not be used in this (‘quirks’) model in jqGrid


We got the above error in an HTML Web Resource which was using jqGrid. The page was working fine in IE 10 browser only in IE 8 we got that error.

The solution was to use the following meta tag inside the HEAD tag of the html page.


<meta
http-equiv=”X-UA-Compatible”
content=”IE=edge”
/>

More details on this meta tag

http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge-e

Hope it helps.

Sample Code: OData Synchronous Call in CRM 2011


Just sharing the sample code to make synchronous OData call in CRM 2011.


var oDataRequestUrl = http://server/orgname/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FullName

var result = syncODataCall(oDataRequestUrl);

// function to make synchronous oData call
 function syncODataCall(odataSelect) {
 var request = new XMLHttpRequest();
 request.open("GET", odataSelect, false);
 request.setRequestHeader("Accept", "application/json");
 request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 request.send();
 var objJQuery = jQuery.parseJSON(request.responseText);
 return objJQuery.d
 }

Check for following methods to parse the result returned

  • ProcessReturnedEntities(data.d.results)
  • ProcessReturnedEntity(data.d)

http://crmscape.blogspot.in/2011/03/crm-2011-odata-json-and-crm-forms.html

Hope it helps !