Bhoopathi

"Be Somebody Nobody Thought You could Be"

Tuesday, April 4

Improving MS Dynamics CRM Performance

Improving MS CRM Performance:

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more approach we can improve the performance bit more.
In IIS setting of a website where MS CRM is hosted, there we can change the Output Cache property. By changing this property to true, initially any entity record load may take bit time; later on it will open the records in much lesser time. This is quite a good approach to improve the performance.
Below screenshot explains where to change the output Cache settings

Open IIS, click on Microsoft Dynamics CRM site-> On Right side Panel click on Feature View-> Configuration Editor









































(source of below description: MSDN)
What is omitVaryStart:
Gets or sets a value indicating whether the vary header is enabled.


true if the vary header is enabled; otherwise, false. The default is false.

The vary header indicates the request-header fields that the server uses to determine which of multiple cached responses are sent in response to a client request. The default for the OmitVaryStar property is false. By default, ASP.NET sends the vary header in all POST requests, as well as in all GET-request query strings. If the OmitVaryStar is true, ASP.NET omits the vary header when returning the response for cached pages, provided that the GET request to a response is cached with no VaryByCustom property and thePOST request to a response is cached with no VaryByParam property and no VaryByCustom property.

Enable Tracing in MS CRM 2015 & Below versions

Enable Tracing in MS CRM 2015 & Below versions

Enabling MS CRM tracing till 2015 new feature is through Registry keys only. But MS CRM 2015 gives this feature as UI. It is really useful for reading the errors we are getting in Plugins and workflow.

Below are the steps to enable to tacing in MS CRM 2015.

1. MS CRM 2015 --- Settings --->Administration ---> System Settings ---> Customization Tab--->
set Enable logging to plug-in trace log as "Exception" as shown in below screen.

























Thats it, now we can read our exceptions in CRM application itself under below path.

Settings---> Plug-in Trace Log


Trace log contains information related to Configuration, TypeName, MessageName, PrimaryEntity, OperationType, Depth, StpeId, CorrelationId, Mode, ExecutionTime, Duration, Excetion Message & Detail, Full Stack.

For CRM 2013 and below versions, we can enable the tracing through registry keys on CRM server.

1. Windows->Run-> Type "regedit" (You should have administrator role to open this registry)
In Registry Editory:
2. HKEY-LOCAL_MACHINE-->SOFTWARE --->Microsoft ---> MS CRM
3. In Right side panel , you can find two DWords called TraceEnabled and TraceRefresh
4. Right click on TraceEnabled DWord ---> Modify ----> Set ValueData to "1" to enable tracing or set ValueData to "0" to disable the Tracing.
5. After you set the value for TraceEnabled, Righ click on TraceRefresh DWord ---> Modify ---> Give any numeric number (Preferably two digit number). TraceEnable will not be reflect until you refresh the tracing through TraceRefresh Dword


If you don't find those DWords in RegistryEditor in given path. then add those DWords
1. Right click on MSCRM ---> New---> DWord(32-bit) value ---> Give name as "TraceEnabled" set Value data as 0.
similary create a DWord for TraceRefresh with data value as any two digit number ex.22

Trace files will be generated in  Trace folder which is in where MS CRM software get installed.

Tuesday, March 21

Filtered Lookup without using JScript in MS CRM 2011

In order to filtering lookup  we have taken two entities called Colleges and Courses.
College is the parent entity for Course it means Course having N:1 relationship with College.

In our scenario we have an Exam entity which consists of College and Course Lookups.

When we are selecting a College, list of Courses related(Associated Courses) to this particular college has to be displayed in Course lookup field.

See below picture before filtering course lookup field it is showing all the records available in Course.



In order to make changes according to our requirement, I have did changes in customization.

Open Exam Entity Form there you will find "Course" Lookup Filed, double click on it and select "Related Records Filtering" option in Field Properties form.

As shown below:


click OK and publish customization.

Here is our requirement result when you are selecting a College, the related records associated with that college will display in Course Lookup Field.





 Thanks
Happy CRM'ing



Disable lookup hyperlinks on form using JavaScript in Dynamics CRM 2011

Use following JavaScript functions to disable lookup fields hyperlinks on Header, Body, Footer sections on any CRM form
Example method to disable Owner and Primary Contact fields on Header, PrimaryContact field on Body and CreatedBy,ModifiedBy fields on Footer on Account form
Call DisableLinks() in the account form load and include other methods in Account entity JavaScript file.
 
Before applying Script
Before
After applying Script
After

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//disable Owner field on Header, Account field on Body and CreatedBy field on Footer
function DisableLinks() {
    DisableHeaderLinks("ownerid");
    DisableHeaderLinks("primarycontactid");
    DisableLookupLinks("primarycontactid");
    DisableFooterLinks("createdby");
    DisableFooterLinks("modifiedby");
}
//to disable Lookup hyderlinks
function DisableLookupLinks(lookupFieldName) {
    var lookupParentNode = document.getElementById(lookupFieldName + "_d");
    var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN");
 
    for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) {
        var currentSpan = lookupSpanNodes[spanIndex];
 
        // Hide the hyperlink formatting
        currentSpan.style.textDecoration = "none";
        currentSpan.style.color = "#000000";
 
        // Revoke click functionality
        currentSpan.onclick = function () { };
    }
}
//to disable Footer hyperlinks
function DisableFooterLinks(lookupFieldName) {
    var lookupParentNode = document.getElementById("footer_" + lookupFieldName + "_d");
    var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN");
 
    for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) {
        var currentSpan = lookupSpanNodes[spanIndex];
 
        // Hide the hyperlink formatting
        currentSpan.style.textDecoration = "none";
        currentSpan.style.color = "#000000";
 
        // Revoke click functionality
        currentSpan.onclick = function () { };
    }
}
 
//to disable Header hyperlinks
function DisableHeaderLinks(lookupFieldName) {
    var lookupParentNode = document.getElementById("header_" + lookupFieldName + "_d");
    var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN");
 
    for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) {
        var currentSpan = lookupSpanNodes[spanIndex];
 
        // Hide the hyperlink formatting
        currentSpan.style.textDecoration = "none";
        currentSpan.style.color = "#000000";
 
        // Revoke click functionality
        currentSpan.onclick = function () { };
    }
}

Get Login User Role name(s) in JavaScript using OData in Dynamics CRM 2011

Here is the sample JavaScript code to get login user role.
Make sure you have added jquery-1.9.1.min.js and JSON2.js in Entity form libraries.If not you can download these from following URL’s
http://jquery.com/download/
http://www.json.org/js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Check login User has 'System Administrator' role
function CheckUserRole() {
    var currentUserRoles = Xrm.Page.context.getUserRoles();
    for (var i = 0; i < currentUserRoles.length; i++) {
         var userRoleId = currentUserRoles[i];
    var userRoleName = GetRoleName(userRoleId);
        if (userRoleName == "System Administrator") {
            return true;
        }
    }
    return false;
}
 
//Get Rolename based on RoleId
function GetRoleName(roleId) {
    //var serverUrl = Xrm.Page.context.getServerUrl();
    var serverUrl = location.protocol + "//" + location.host + "/" + Xrm.Page.context.getOrgUniqueName();
    var odataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc" + "/" + "RoleSet?$filter=RoleId eq guid'" + roleId + "'";
    var roleName = null;
    $.ajax(
        {
            type: "GET",
            async: false,
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: odataSelect,
            beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
            success: function (data, textStatus, XmlHttpRequest) {
                roleName = data.d.results[0].Name;
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + textStatus + errorThrown + odataSelect); }
        }
    );
    return roleName;
}