Plugin Deployment Options – Dynamics CRM

The 3 storage options are: Database, Disk and GAC. The main differences between these are:

Database: The assembly dll is stored in the database, rather than the file system. The major advantages are that the assembly need only be deployed once multiple CRM servers are available, and that no additional action is required to restore / redeploy the assembly either during disaster recovery, or if redeploying to an alternate server. This is the preferred option in a production environment

Disk: The assembly dll is placed in the \server\bin\assembly directory on each server. Have to ensure the dll is placed in the correct place on all CRM servers, so the deployment overhead is a little greater. Better to use this option in development environments as the developer can redeploy newer versions solely by file transfer, rather than reregistering. Also, if debugging, the assembly .pdb file needs to be placed in the same location; with this option it’s easy to ensure the dll and pdb are from the same build

GAC: The assembly is placed in the Global Assembly Cache on each CRM server, and again will have to do this. The GAC does allow multiple versions of an assembly, but CRM doesn’t, so don’t really gain anything by using the GAC.

According to my experience deploying the plugin assemblies to the Database is the best option as we can backup and restore the databases and minimizing assemblies deployments and other setting changes.


Set Server Url to OData Query Dynamically using JavaScripts in CRM 2011 Forms

Following statement can be used to retrieve accounts from the CRM application with the MyOrganization hosted in DevServer.


http://DevServer/MyOrganisation/” part is varried according to the hosted server and the organization and it might raise errors when the above OData query get executed in some other CRM application.

Following JavaScript can be used to get the server url in the CRM 2011 forms.

var serverUrl = Xrm.Page.context.getServerUrl();

Get the next part of the OData service part.

var GlobalODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc/";

Continue reading “Set Server Url to OData Query Dynamically using JavaScripts in CRM 2011 Forms”

Application Pool Recycling instead of Restarting IIS – CRM App Pool

Restarting or stopping IIS, or rebooting the Web server, is a server action. When restarting the Internet service, all sessions connected to the Web server (including Internet, FTP, SMTP, and NNTP) are dropped. Any data held in Web applications is lost. All Internet sites are unavailable until Internet services are restarted. For this reason, we should avoid restarting, stopping, or reboot the server if at all possible. IIS 6.0 includes application pool recycling and several other features that provide alternatives to restarting IIS. For a list of features designed to improve IIS reliability and remedy the need to restart IIS.

Restarting IIS (IIS 6.0)

All of the Internet services listed below, if installed, are affected when restarting IIS

Service Description
IIS Admin service This service manages all the services of IIS other than the WWW service (FTP, NMTP, and SMTP).
WWW service This service provides Web connectivity between clients and Web sites.
HTTP SSL service This service provides secure Web connectivity between clients and Web sites.
FTP service This service provides FTP connectivity and administration through IIS Manager.
SMTP service This service transports electronic mail across the network.
NNTP service This service transports network news across the network.

Internet Information Services (IIS) can be configured to periodically restart worker processes assigned to an application pool, which recycles faulty Web applications. Following example shows how to do it manually or using a batch file in a CRM environment.

Continue reading “Application Pool Recycling instead of Restarting IIS – CRM App Pool”

Useful Javascripts for CRM 2011

// Get the form type
GetFormType: function () {

 var formType = Xrm.Page.ui.getFormType();
 if (formType == FORM_TYPE_CREATE) {
  alert("This record has not yet been created.");
 else {
  alert("This record exists in the database.");

// Registering an event for a custom control, and call a method when it fires
RegisterEventForACustomControl: function (var controlId) {
        var customField = document.getElementById(controlId);
        /* Build Toggle Function */
        var f = "var ef=function() { " +
                  "MethodToBeCalled();" +
                  " };";
        /* Attach to click event */
        customField.attachEvent('onclick', ef, false);

MethodToBeCalled: function () {
        // Do something

// Disable/Enable all controls in a Tab
DisableAllControlsInTab: function (tabName, isDisable) {
    var tabControl = Xrm.Page.ui.tabs.get(tabName);
    if (tabControl != null) {
        function (control, index) {
            if (control.getParent().getParent() == tabControl && control.getControlType() != "subgrid") {

// Get the value from a CRM field
var varMyValue = Xrm.Page.getAttribute("CRMFieldSchemaName”).getValue() ;

// Set the value of a CRM field
Xrm.Page.getAttribute("CRMFieldSchemaName”).setValue(‘New Value’);

// Hide/Show a tab using 


// Hide/Show a section in a tab

// Call the onchange event of a field

// Get the selected value of picklist

// Set the requirement level

// Set the focus to a field

// Return array of strings of users security role GUIDs:

// Setting Force Submit to the field, This must be set to save the data

// Stop an on save event
event.returnValue = false;

// Form close

Microsoft Dynamics CRM 2011 – Hide Areas of a Form

// Toggle the Ribbon Toolbar to Show/Hide (same as clicking the show/hide Ribbon button)"minimizeribbon").fireEvent("onclick");

// Hide the Ribbon Toolbar and move the form Content area to the top of the window."crmTopBar").style.display = "none";"crmContentPanel") = "0px"; // Move Form Content area up to top of window, initial is 135px

// Hide Left Hand Nav bar / pane
document.getElementById("crmNavBar") = "none";
document.getElementById("tdAreas").parentElement.parentElement.parentElement.parentElement.colSpan = 2;

// Hide the Breadcrumb and Record Set Toolbar
document.getElementById("recordSetToolBar") = "none";

// Hide the Form Footer Bar
document.getElementById("crmFormFooter") = "none";

Silverlight – Access UI from code Asynchronously

System.Windows.Threading Namespace provides classes that support the Silverlight threading system.
Dispatcher Class provides services for managing the queue of work items for a thread.

Dispatcher.BeginInvoke Method (Action) executes the specified delegate asynchronously on the thread the Dispatcher is associated with.


Dispatcher.BeginInvoke(() =>
    MessageBox.Show("Member Number does not exist in the system.");
    this.memberNumberTextBox.Text = string.Empty;