CRM Installation Error : Sql instance name must be the same as computer name

When the Sql server instance is differ from the machine name, this error will be given as a result of verification tasks under the system check of CRM installation. Most of the time this happens if the Sql server instance changes after the first installation and reinstallations.

CRM Installation Sql Error
CRM Installation Error

Anyhow this can be fixed easily as we can use few sql stored procedures. Follow the steps listed below.

Continue reading “CRM Installation Error : Sql instance name must be the same as computer name”

Advertisement

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/xrmservices/2011/OrganizationData.svc/AccountSet?$select=swmship_FirstName,swmship_Surname&$filter=startswith(Address1_City,’Ca’)

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 FORM_TYPE_CREATE = 1;
 var FORM_TYPE_UPDATE = 2;
 var FORM_TYPE_READ_ONLY = 3;
 var FORM_TYPE_DISABLED = 4;
 var FORM_TYPE_QUICK_CREATE = 5;
 var FORM_TYPE_BULK_EDIT = 6;

 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();" +
                  " };";
        eval(f);
        /* 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) {
        Xrm.Page.ui.controls.forEach(
        function (control, index) {
            if (control.getParent().getParent() == tabControl && control.getControlType() != "subgrid") {
                control.setDisabled(isDisable);
            }
        });
    }
}




// 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 
Xrm.Page.ui.tabs.get("CRMTabName").setVisible(true);
Xrm.Page.ui.tabs.get("CRMTabName").setVisible(false);

Xrm.Page.ui.tabs.get(5).SetVisible(false);
Xrm.Page.ui.tabs.get(5).SetVisible(true);




// Hide/Show a section in a tab
Xrm.Page.ui.tabs.get("CrmTabName").sections.get("SectionName").setVisible(true);
Xrm.Page.ui.tabs.get("CrmTabName").sections.get("SectionName").setVisible(false);




// Call the onchange event of a field
Xrm.Page.getAttribute("CRMFieldSchemaName”).fireOnChange();




// Get the selected value of picklist
Xrm.Page.getAttribute("CRMFieldSchemaName”).getSelectedOption().getValue();




// Set the requirement level
Xrm.Page.getAttribute("CRMFieldSchemaName”).setRequiredLevel("none”);
Xrm.Page.getAttribute("CRMFieldSchemaName”).setRequiredLevel("required”);
Xrm.Page.getAttribute("CRMFieldSchemaName”).setRequiredLevel("recommended”);




// Set the focus to a field
Xrm.Page.getControl("CRMFieldSchemaName”).setFocus(true);




// Return array of strings of users security role GUIDs:
Xrm.Page.context.getUserRoles()




// Setting Force Submit to the field, This must be set to save the data
Xrm.Page.getAttribute("CRMFieldSchemaName”).setSubmitMode("always”);




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




// Form close
Xrm.Page.ui.close();


Get the CRM server url from Silverlight [If the silverlight page is in a form]

private static String GetServerUrlFromCrmContext()
{
    try
    {
        // If the Silverlight is in a form, this will get the server url
        ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
        if (xrm != null)
        {
            ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
            ScriptObject pageContext = (ScriptObject)page.GetProperty("context");

            String serverUrl = (String)pageContext.Invoke("getServerUrl");
            return serverUrl;
        }
        else
        {
            goto DevUrl;
        }
    }
    catch
    {
        goto DevUrl;
    }

    DevUrl:
    return "http://10.100.4.100:5555/MyOrganization";
}

Reference an Image Web Resource from Site Map SubArea

Adding an image to the site map can be done by two ways.

  1. Giving a image path from the icon folder
  2. Giving a path from the web resources

Giving a path from the web resources is very effective in CRM 2011, as web resources are always reside with CRM Solutions. Follow the steps given below to add an image from web resources.

  • Upload the image as a web resource to the solution. (E.g. swcmt_CommitteesSiteMapIcon24x24)

  • Publish the solution and export the un-managed solution.
  • Extract the zip file and open the “customizations.xml” file from the Visual Studio (or any other xml editor).
  • Find the “<Area>” tag that the new image needed.
  • Modify the xml as follows;

<Area Id="SWCmt" ResourceId="Area_Committee" Title="Committees" ShowGroups="true" Icon=”$webresource:swcmt_CommitteesSiteMapIcon24x24″ DescriptionResourceId=”Committee_Description”>

      
It shows in the CRM application as follows;


Adding a custom button to CRM 2011 Form

Adding a button to a CRM Form is quite challenging as we don’t have any IDE to design it. But still it’s possible using JavaScript.
Here’s the JavaScript code for that.
// Create the button, using the new_custombutton field as a container
        CreateButtonCRM5(‘swpmt_cancelddi’, ‘Cancel DDI’, ’75 px’, ’16_cancel.png’, CustomClickFunction);


// Custom Function
function CustomClickFunction() {
    var response = confirm(“DDI Status is to be changed to ‘Cancelling’. Do you want to continue?”);
    if (response) {
        Xrm.Page.getAttribute(‘swpmt_ddistatus’).setValue(4);
    }
}


// Add a button to the CRM Form – Begin


// CODE
// Create Dynamic Button for CRM 2011
function removeChildNodes(ctrl) {
    while (ctrl.childNodes[0]) {
        ctrl.removeChild(ctrl.childNodes[0]);
    }
}


function CreateButtonCRM5(fieldName, buttonText, buttonWidth, iconName, clickEvent) {
    functiontocall = clickEvent;
    crmForm.all.item(fieldName + “_c”).style.display = “none”;


    var li = document.createElement(“LI”);
    li.setAttribute(‘id’, fieldName + ‘LI’);
    li.setAttribute(‘className’, ‘ms-crm-Menu’);
    li.setAttribute(‘title’, buttonText);
    li.setAttribute(‘onclick’, functiontocall);
    li.setAttribute(‘onmousedown’, push_custom_button);
    li.setAttribute(‘onmouseup’, release_custom_button);
    li.style.width = buttonWidth;
    li.style.cursor = “hand”;
    li.style.textAlign = “center”;
    li.style.overflow = “hidden”;


    var span = document.createElement(“span”);
    span.setAttribute(‘className’, ‘ms-crm-Menu-Label’);
    span.setAttribute(‘id’, fieldName + ‘Span’);
    span.style.cursor = “hand”;
    li.appendChild(span);
    li.onmouseover = function () { span.setAttribute(‘className’, ‘ms-crm-Menu-Label-Hovered’); }
    li.onmouseout = function () { span.setAttribute(‘className’, ‘ms-crm-Menu-Label’); }


    var a = document.createElement(“a”);
    a.setAttribute(‘id’, fieldName + ‘A’);
    a.setAttribute(‘className’, ‘ms-crm-Menu-Label’);
    a.onclick = function () { return false; }
    a.setAttribute(‘target’, ‘_self’);
    a.setAttribute(‘href’, ‘javascript:onclick();’);
    a.style.cursor = “hand”;
    span.appendChild(a);


    var img = document.createElement(“img”);
    img.setAttribute(‘id’, fieldName + ‘Img’);
    img.setAttribute(‘className’, ‘ms-crm-Menu-ButtonFirst’);
    img.setAttribute(‘src’, ‘/_imgs/ico/’ + iconName);
    img.style.cursor = “hand”;


    var span2 = document.createElement(“span”);
    span2.setAttribute(‘id’, fieldName + ‘Span2’);
    span2.setAttribute(‘className’, ‘ms-crm-MenuItem-TextRTL’);
    span2.innerText = buttonText;
    span2.style.cursor = “hand”;
    a.appendChild(img);
    a.appendChild(span2);


    removeChildNodes(crmForm.all.item(fieldName + “_d”));
    crmForm.all.item(fieldName + “_d”).appendChild(li);
}


function push_custom_button() {
    window.event.srcElement.style.marginLeft = “1px”;
    window.event.srcElement.style.marginTop = “1px”;
}


function release_custom_button() {
    window.event.srcElement.style.marginLeft = “0px”;
    window.event.srcElement.style.marginTop = “0px”;
}


// Add a button to the CRM Form – End