Friday, 28 September 2012

Some of the CRM Blogs:

Ronald Lemmen -
Philip Richardson -
Gonzalo Ruiz -
Ross Lotharius -
CRM Team Blog -
Andy Bybee -
Ben Riga -
Ben Vollmer -
Menno te Koppele -
Simon Hutson -
Aaron Elder -
Frank Lee -
Guy Riddle -
Matt Witteman -
Michael Höhne -
Mitch Milam -
Scott Colson -


A good link , which explains clearly silver light webresource developmet in mscrm 2011 using rest end point:


Code snippet for custom wcf service calling from mscrm 2011 form java script:

Call the Custom WCF request in Java Script:

Var xmlhttp = new XMLHttpRequest ();

Retrieve the WCF URL from from “ApplicationConfig” Entity using following method.

Var WcfServiceUrlValue= GetConfigValueByKey (Key Name);

WcfServiceUrlValue=WcfServiceUrlValue.avd_ConfigValue;'POST', WcfServiceUrlValue , false);

//Get the request XML from WCF Test Client or Using Feddler Tool

//Place the Inteface name and Method Name following highlighted text.

xmlhttp.setRequestHeader('SOAPAction', ' ');

xmlhttp.setRequestHeader('Content-Type', 'text/xml');

var data = '';

data+='<s:Envelope xmlns:s="">';


   data+='UpdateExpiredCheque  xmlns="">';

   data+='<data xmlns:d4p1=" UU.Crm.WCFService.DataContracts" xmlns:i="">';









  data += '</s:Envelope>';


            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

            xmlDoc.async = false;


//Check the Response Object  and Retrieve the tag values following way.

if (xmlDoc.xml != "") {

                var Msg;

                var ResponseCollection = xmlDoc.getElementsByTagName("a:ResponseCollection");

                if (ResponseCollection.length > 0) {

                    if (ResponseCollection[0].firstChild != null) {

                        Msg = "Message Severity :" + ResponseCollection[0].firstChild.childNodes[0].nodeTypedValue + '\n';

                        Msg += "Warning :" + ResponseCollection[0].firstChild.childNodes[1].nodeTypedValue;





Friday, 21 September 2012

Sample code to modify the users  last viewed form id :

CRM saves the Id of the last form that a user viewed using the UserEntityUISettings entity, and any UserEntityUISettings record can be easily updated to set the Last Viewed form for a specific user:

//retrieve the user UI settings for a specific user and a specified entity:
QueryExpression query = new QueryExpression(UserEntityUISettings.EntityLogicalName);
query.Criteria.AddCondition("ownerid", ConditionOperator.Equal, userId);
query.Criteria.AddCondition("objecttypecode", ConditionOperator.Equal, entityObjectTypeCode);
EntityCollection UISettingsCollection = service.RetrieveMultiple(query);
if (UISettingsCollection.Entities.Count > 0)
//update the last viewed formId:
UserEntityUISettings settings = (UserEntityUISettings)UISettingsCollection[0];
settings.LastViewedFormXml = "<MRUForm><Form Type=\"Main\" Id=\"f5cfab6a-d4c2-4519-b68f-6e7485432e29\" /></MRUForm>";

ODATA  restrictions in mscrm 2011:




· Max expansion 6
· Page size is fixed to max 50 records
· $top gives the total records returned across multiple pages
· When using with distinct queries, we are limited to the total (skip + top) record size = 5000.
· In CRM the distinct queries does not use paging cookie are and so we are limited by the CRM platform limitation to the 5000 record.
· One level of navigation property selection is allowed I.e.
· Conditions on only one group of attributes are allowed. By a group of attribute I am referring to a set of conditions joined by And/Or clause.
· The attribute group may be on the root entity
.../TaskSet?$expand=Contact_Tasks&$filter=Subject eq 'test' and Subject ne null
· (or) on the expanded entity.
.../TaskSet?$expand=Contact_Tasks&$filter=Contact_Tasks/FirstName eq '123‘
· Arithmetic, datetime and math operators are not supported
· Under string function we support Substringof, endswith, startswith
· Order are only allowed on the root entity.
· Only one level of navigation is allowed in any direction of a relationship. The relationship could be 1:N, N:1, N:N
Accessing context data  in silvrlight webresource like cr for javascript:

If your Silverlight web resource is designed to be viewed in an entity form, the form has an Xrm.Page.context object you can use to access contextual information.
If you need your Silverlight application to appear outside the context of the form you must configure an HTML web resource to provide this context information by adding a reference to the ClientGlobalContext.js.aspx page. After this reference is added, your Silverlight application can access contextual information in the same way it can in an entity form. The following sample shows how to call the getServerUrl function from the Xrm.Page.context object.

private string serverUrl = "";
ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
ScriptObject pageContext = (ScriptObject)page.GetProperty("context");
serverUrl = (string)pageContext.Invoke("getServerUrl");

Friday, 14 September 2012

Mscrm 2011 Plugin basic code snippsets:

Code to extract service objects:

IPluginExecutionContext context =



            // Get a reference to the organization service.

            IOrganizationServiceFactory factory =


            IOrganizationService service = factory.CreateOrganizationService(context.UserId);


            // Get a reference to the tracing service.

            ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));


Getting input parameters:

if (context.InputParameters.Contains("Target") &&

    context.InputParameters["Target"] is Entity)


    // Obtain the target entity from the input parmameters.

    Entity entity = (Entity)context.InputParameters["Target"];

Shared variable:

context.SharedVariables.Add("PrimaryContact", (Object)contact.ToString());

if (context.SharedVariables.Contains("PrimaryContact"))


                Guid contact =

                    new Guid((string)context.SharedVariables["PrimaryContact"]);


                // Do something with the contact.


Image reading:

if (context.PreEntityImages.Contains("PreImage") &&
    context.PreEntityImages["PreImage"] is Entity)


    preMessageImage = (Entity)context.PreEntityImages["PreImage"];





Query expression class:

//  Create query using querybyattribute

    QueryByAttribute querybyexpression = new QueryByAttribute("account");

    querybyexpression.ColumnSet = new ColumnSet("name", "address1_city", "emailaddress1");

//  Attribute to query


//  Value of queried attribute to return



//  Query passed to the service proxy

    EntityCollection retrieved = _serviceProxy.RetrieveMultiple(querybyexpression);


//  Iterate through returned collection

    foreach (var c in retrieved.Entities)


       System.Console.WriteLine("Name: " + c.Attributes["name"]);

       System.Console.WriteLine("Address: " + c.Attributes["address1_city"]);

       System.Console.WriteLine("E-mail: " + c.Attributes["emailaddress1"]);



//  Query using ConditionExpression and FilterExpression

ConditionExpression condition1 = new ConditionExpression();

condition1.AttributeName = "lastname";

condition1.Operator = ConditionOperator.Equal;



FilterExpression filter1 = new FilterExpression();



QueryExpression query = new QueryExpression("contact");

query.ColumnSet.AddColumns("firstname", "lastname");



EntityCollection result1 = _serviceProxy.RetrieveMultiple(query);



QueryExpression contactquery = new QueryExpression



                            ColumnSet = new ColumnSet("firstname", "lastname", "contactid")



Registry setting in mscrm


How to modify the no of records count retrieved by fetch xml more than 5000:


·         Click Start, click Run, type regedit in the Open box, and then click OK.

·         Locate and then select the following registry subkey:

·         HKEY_LOCAL_MACHINE\Software\Microsoft\MSCRM

·         On the Edit menu, point to New, and then click DWORD Value.

·         Type TurnOffFetchThrottling, and then press ENTER.

·         Right-click TurnOffFetchThrottling, and then click Modify.

·         Type a number other than 0 in the Value data box, and then click OK.Note Step 6 lets you retrieve the number of records specified in the Couast attribute of your fetch statement.

·         On the File menu, click Exit.


Modifying attachement size limit:

You can find the client key here:




Enabling Tracing:


Data value
A value of 0 or 1
If you use a value of 0, tracing is disabled. If you use a value of 1, tracing is enabled.
The TraceDirectory registry entry specifies the directory for the trace log files. The directory must exist, and the user who starts the Microsoft CRMAppPool must have full control over this directory. When you install Microsoft CRM, the default user is NT AUTHORITY\NETWORK SERVICE.
A number between zero and 99
When the data is changed, the trace settings in the other trace registry entries are applied.

Optional registry entries

The following are the optional registry entries.

Collapse this tableExpand this table

Data value
String or Multi-String
The TraceCategories registry entry is a combination of a category, a feature, and a trace level. You can specify multiple categories, features, and trace levels. Separate each combination by using a semicolon. For a list of categories, features, and trace levels and for sample combinations that are valid, see the "Trace level values" section.
A value of 0 or 1
If you use a value of 0, the call stack is not included in the trace file. If you use a value of 1, the call stack is included in the trace file.
A size between 1 and 100 MB
The TraceFileSizeLimit registry entry specifies the maximum size of trace files. New files are created when the limit is reached.



Registry Setting
For Hosted Microsoft Dynamics CRM 3.0 release only. Used to control authentication in a hosted environment.
Used to allow unresolved parties on e-mail send.
For Hosted Microsoft Dynamics CRM 3.0 release only. Used to control authentication in a hosted environment.
Returns unmanaged code exceptions.
Returns managed code exceptions.
Used to override the location Microsoft CRM searches for fax cover pages on Microsoft CRM SBE installed on SBS.
Used to allow the Outlook client to load regardless of error conditions.
Used to enable performance tracing.
Used to get additional details when using logging.
Used to specify the level of tracing.
Used to indicate the number of records to export to Microsoft Excel.
Specifies the maximum number of rows returned from a Fetch query.
Used to set the size limit for files uploaded to Microsoft CRM through Bulk Import or as attachments.*
Used to change the installation path for the Microsoft CRM Desktop Client.
For Hosted Microsoft Dynamics CRM 3.0 release only. Used to specify the URLs for viewing reports. Multiple URLs are supported for multiple server configurations.
Updated by appending an ‘s’ at the end of the ‘http’ value after enabling Secure Socket Layers (SSL) after the Microsoft CRM server is installed.
For Hosted Microsoft Dynamics CRM 3.0 release only. Used to control authentication in a hosted environment.
Used to override the codepage used when sending e-mail in Microsoft CRM.
Used to set the timeout value for the Post Url action.
Updated by appending an ‘s’ at the end of the ‘http’ value after enabling Secure Socket Layers (SSL) after the Microsoft CRM server is installed.
Used to set the timeout value for .NET assemblies.
Specifies whether or not to use the value set for MaxRowsPerPage.
Controls the time interval (in seconds) for workflow service pooling the event log table. Used to configure the workflow pooling interval.
Used to configure the number of threads run by the workflow service.
Used to indicate that the Post Url action should post security information.