Tuesday, December 24, 2013

Commands

        Below are the useful commands used in Microsoft related products like .Net, CRM,...

Click on the item below to go through the description about that.

Assembly Registration:

The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently.

If you’re running Visual Studio on Windows 7: Choose Start, and then choose All Programs, Microsoft Visual Studio, Visual Studio Tools, Visual Studio Command Prompt.
                    
regasm <DLLFilePath> /codebase /tlb

Ex: regasm C:\Testing.dll /codebase /tlb
                    
                

ILMerge:

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly.

- Download ILMerge software from here and install in your machine.
- Goto Start, Run, cmd, OK.
- Goto C:\Program Files (x86)\Microsoft\ILMerge folder path and run below command.
                    
ilmerge /lib:<AssembliesFolderPath> <DLL1> <DLL2> <DLL3> <DLL4> /out:<OutputDLL>

Ex: ilmerge /lib:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies" C:\FirstDLL.dll C:\SecondDLL.dll C:\ThirdDLL.dll /out:C:\FinalDLL.dll
                    
                

Create Early Bound Classes:

CrmSvcUtil.exe is a command-line code generation tool for use with Microsoft Dynamics CRM 2011. This tool generates early-bound .NET Framework classes that represent the entity data model used by Microsoft Dynamics CRM. This tool is in the SDK download package in the SDK\Bin folder.

- Goto Start, Run, cmd, OK.
- Goto SDK\bin folder path and run below command.
                    
CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:<OutputFile> /url:<OrganizationURL> /domain:<Domain> /username:<UserName> /password:<Password> /namespace:<Namespace> /serviceContextName:<serviceContext>
Ex: CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm\Xrm.cs /url:http://MyCRM/MyOrg/XRMServices/2011/Organization.svc /domain:mscrm /username:administrator /password:mypassword123 /namespace:Xrm /serviceContextName:XrmServiceContext
For Online instance, you need to register your device as here.
                    
                    
CrmSvcUtil.exe /url:<OrgnizationURL> /out:<OutputFile> /username:<UserName> /password:<Password> /deviceid:<DeviceID> /devicepassword:<DevicePassword>
Ex: CrmSvcUtil.exe /url:https://myorg.crm.dynamics.com/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:"myname@live.com" /password:"mypassword123" /deviceid:"9eqd9qip4meckbxhyi838gn3" /devicepassword:"543opae9itRWKO+U7fe+I3MRVANUyFFPcfDJYP5ItZo="
                    
                

Device Registration:

CRM SDK has provided a tool to register your device. Goto Command Prompt then to the folder path SDK\tools\deviceregistration\bin\Debug. Run below command. This will register you device and give Device Username and Device Password.
                    
deviceregistration.exe /operation:Register
                    
                

Monday, November 25, 2013

JQuery

        Below are the few useful statement, commands in JQuery.

Click on the item below to go through the description about that.

Disable the Control:

Disable the HTML controls like button, checkbox, textbox.
                    
$('#btn_submit').attr("disabled", true);
                    
                

Define the click event action:

Define the set of statements to be executed on click of control.
                    
$(document).ready(function () {
    $("#btn_submit").click(function () {
      // Click event action
    });
});
                    
                

Slide Taggle:

Slide taggle the content.
                    
$(".OnlineTable").slideToggle("slow");
                    
                

Get is checkbox checked:

Get the checkbox value. True, if checked. False, if unchecked.
                    
if($("#tdCheckBox").checked) {
    alert("Checked.");
}
else {
    alert("Unchecked.");
}
                    
                

Append the HTML tags:

Append the HTML tags inside another tag. In below example, <tr> tag is inserting into the <table> tag.
                    
$("#detail_table").append(
    "<tr>" +
    "<td class='thCheckbox' style='text-align:center;'>" +
    "<input type='checkbox' class='tdCheckBox' checked disabled /></<td>" +
    "<td><a class='anchor'>Full Name</a></td>" +
    "<td>E-Mail Id</td>" +
    "<td style='display:none;'>SSN</td>" +
    "</tr>"
);
                    
                

Tuesday, September 24, 2013

Retrieve query string parameter values in Javascript


Below is the Javascript code to fetch the query string parameter values.

function buttonClick() {

    var _QS = getQueryString();

    if (_QS['data'] == 'service') {
        // Service logic here
    }
    else if (_QS['data'] == 'sales') {
        // Sales logic here
    }
}

function getQueryString() {

    var _queryString = {};
    var _query = window.location.search.substring(1);
    
    // Split the parameters
    var _vars = _query.split("&");

    for (var i = 0; i < _vars.length; i++) {

        // Split the Name & Value pair
        var _pair = _vars[i].split("=");

        if (typeof _queryString[_pair[0]] === "undefined") {
            _queryString[_pair[0]] = _pair[1];

        } else if (typeof _queryString[_pair[0]] === "string") {
            var _array = [_queryString[_pair[0]], _pair[1]];
            _queryString[_pair[0]] = _array;

        } else {
            _queryString[_pair[0]].push(_pair[1]);
        }
    }

    return _queryString;
}

Saturday, April 6, 2013

Related records count in CRM 2011 chart

        Below is the screenshot of  Cases associated with Contact record(Fig. A). Here we can see two Cases for this Contact. In this exercise, the requirement is to display the related Case count for each Contacts in an Organization using charts.

Fig. A. Cases associated with Contact


Follow the below steps to create this chart in MSCRM2011.
  • Settings à Customizations à Customize the System à Entities à Case à Charts à New.
  • Name the chart à Select Case(Count) in Series and any field in Horizontal à Save & Close.
  • Select newly created chart à More Actions à Export Chart.
  • Open exported chart in Visual Studio.
  • Replace <entity> tag with below XML and Save.
    <entity name="incident">
        <attribute alias="_CRMAutoGen_aggregate_column_Num_0" name="incidentid" aggregate="count" />
       <link-entity name="contact" from="contactid" to="customerid" alias="aa">
            <attribute name="fullname" groupby="true" alias="_CRMAutoGen_groupby_column_Num_0"  />
            <filter type="and">
                <condition attribute="statecode" operator="eq" value="0"/>
            </filter>
        </link-entity>
    </entity>

  • In Charts, More Actions à Import Chart à Browse for updated XML file à OK à Replace à Close.
  • You can add this chart to Dashboard and which will looks like below(Fig. B).
Fig. B. Contact Vs Case count chart in Dashboard.

Friday, March 15, 2013

Dependent Picklist(Dynamic Option Set) in CRM 2011

             MS CRM 2011 doesn't have Out-Of-the-Box functionality to filter the option set values based on the value selected in another option set. We can implement this functionality using Javascript. Lets consider one example here. We have two option set fields called Country and City. City field has to be filtered based on the value selected in Country field. Below JScript code will do this functionality.

Prerequisite:

1. Create two optionset fields named new_country(with values say, India, USA and Srilanka) and new_city(with values say, Bangalore, Delhi, New York, Colombo, California and Hyderabad).
2. Create a JScript Webresource with the below code.
3. Attach this webrecource to call optionSetChanged() method on change of Country field and OnLoad of the form.
4. Configure getCollection() method to match the Cities with respect to Country.


/************************
Functionality: To populate the picklist values based on the value selected in another picklist.
Field Name: new_country
Field Event: OnChange, OnLoad
***************************/

function optionSetChanged() {

    ///<summary>
    /// Change the dependent picklist values based on the value selected in the control picklist.
    ///</summary>

    var _collection = getCollection();
    var _selectedCity = null;
    var _cityOptionset = Xrm.Page.ui.controls.get("new_city");
    if (_cityOptionset != null)
        _selectedCity = _cityOptionset.getAttribute().getValue();

    var _cityOptions = _cityOptionset.getAttribute().getOptions();
    var _selectedCountry = Xrm.Page.getAttribute("new_country").getText();
        
    // If Country is empty, then clear the City field.
    if (_selectedCountry == "") {
        _cityOptionset.clearOptions();
    }
    else {
        for (var i = 0; i < _collection.length; i++) {
            if (_selectedCountry.toLowerCase() == _collection[i].Country.toLowerCase()) {
                _cityOptionset.clearOptions();
                for (var j = 0; j < _collection[i].Cities.length; j++) {
                    for (var k = 0; k < _cityOptions.length; k++) {
                        if (_collection[i].Cities[j].toLowerCase() == _cityOptions[k].text.toLowerCase()) {
                            _cityOptionset.addOption(_cityOptions[k]);
                            break;
                        }
                    }
                }
                break;
            }
        }
        if (_cityOptionset != null && _selectedCity != null)
            _cityOptionset.getAttribute().setValue(_selectedCity);
    }
}


function getCollection() {

    ///<summary>
    /// Creates and returns a collection of Cities with respect to their Countries.
    ///</summary>

    var _collection = new Array();
    var India_Cities = new Array("Bangalore", "Delhi", "Hyderabad");
    var India_obj = { Country: "India", Cities: India_Cities };
    _collection.push(India_obj);

    var Srilanka_Cities = new Array("Colombo");
    var SriLanka_obj = { Country: "SriLanka", Cities: Srilanka_Cities };
    _collection.push(SriLanka_obj);

    var USA_Cities = new Array("California", "New York");
    var USA_obj = { Country: "USA", Cities: USA_Cities };
    _collection.push(USA_obj);

    return _collection;
}



    This functionality can be tested by changing the Country field and check the values populated in City field. Result of this dependent pick list is can be seen here.

Country: India and Cities: Bangalore,Delhi & Hyderabad.

Country: USA and Cities: California & NewYork.