Monthly Archives: June 2012

MS CRM 2011 Technical Interview Answer Part -1

In my MS CRM 2011 Technical Interview Question Part -1 post, I got comments to write answers for interview question, so here is the first post for answers: 

  • Explain some new features in MS CRM 2011.

–         There are many new featues in MS CRM 2011 like Enhanced UI,OOB Dashboard support,Auditing support,Field level security, Connections,Solution,Webresource, Role based Forms, refer: for more details. 

  • What are the different webservice available in MS CRM 2011.

–         MS CRM 2011 have two webservices IOrganization Service, IDiscoveryService

  • Which service can be used to access metadata information.

–         We can use IOrganization Service to fetch metadata.

  • What are the different ways to consume MS CRM webservice from client side?

–         We can write Rest or Soap request to consume MS CRM 2011 webservices.

  • Rest Vs Soap.

–         Please refer:

  • Difference between Dialog and Workflow.

–         Dialogs are synchronous process and Workflows are asynchronous process.

–         We can develop custom workflow, but can’t customize dialogs.

–         Refer :

  • What is Solution?

–         Solution is a collection of MS CRM 2011 components that can be exported and imported easily from one CRM organization to another CRM organization.

  • Difference between Managed and unmanaged solution.

–         Managed solution can’t be customized, but can be uninstalled easily.

–         Unmanaged solution can be customized, you can’t uninstall unmanaged solution.

–         Refer : for more details

  • Is it possible to register plugin through solution?

–         Yes.

  • What is field level security?

–         Using field level security we can hide information based on user security role in MS CRM 2011. Refer :

  • How can we use auditing in MS CRM 2011.

–         Auditing can be configured easily through CRM UI. Refer: for more details on auditing.

I will cover rest of the question in my next post.




Filed under MS CRM 2011

Get Optionset Label based on Optionset value using Javascript

I got one requirement to fetch optionset lable based on it’s value, then I found this post  which helped me to write required script. We can write a Soap request to fetch optionset metadata based on it’s metadata id (Guid for global optionset, you can capture global optionset guid from URL through opening global optionset record). once you have guid you can write a Soap request like below, make sure to change metadataid and optionsetname

 function GetOptionsetLable(_Value) {
    var _ServerURL = Xrm.Page.context.getServerUrl() + “/XRMServices/2011/Organization.svc/web”;
    var MetadaID = “xxxx-xxx-xxx…”; //Optionset guid
    var _OptionLabel = null;
    var xmlrequest = “<s:Envelope xmlns:s=\”\“>” +
    “<s:Body>” +
    “<Execute xmlns=\”\” xmlns:i=\”\“>” +
    “<request i:type=\”a:RetrieveOptionSetRequest\” xmlns:a=\”\“>” +
    “<a:Parameters xmlns:b=\”\“>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>MetadataId</b:key>” +
    “<b:value i:type=\”c:guid\” xmlns:c=\”\”>”+MetadaID+”</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>RetrieveAsIfPublished</b:key>” +
    “<b:value i:type=\”c:boolean\” xmlns:c=\”\”>false</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>Name</b:key>” +
    “<b:value i:type=\”c:string\” xmlns:c=\”\”>OptionsetName</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “</a:Parameters>” +
    “<a:RequestId i:nil=\”true\” />” +
    “<a:RequestName>RetrieveOptionSet</a:RequestName>” +
    var req = new XMLHttpRequest();“POST”, _ServerURL, false)
    req.setRequestHeader(“Accept”, “application/xml, text/xml, */*”);
    req.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
    req.setRequestHeader(“SOAPAction”, ““);
    var resultXml = req.responseXML;

    var errorCount = resultXml.selectNodes(‘//error’).length;
    if (errorCount != 0) {
        var msg = resultXml.selectSingleNode(‘//description’).nodeTypedValue;
    else {
        var oXmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
        oXmlDoc.async = false;
        var results = oXmlDoc.getElementsByTagName(“ExecuteResponse/ExecuteResult/a:Results/a:KeyValuePairOfstringanyType/b:value/c:Options/c:OptionMetadata”);
        for (i = 0; i < results.length; i++) {
            var _Name = results[i].selectSingleNode(‘./c:Label/a:LocalizedLabels/a:LocalizedLabel/a:Label’).nodeTypedValue;
            var Optionvalue = results[i].selectSingleNode(‘./c:Value’).nodeTypedValue;
            if (_Value == Optionvalue) {
                _OptionLabel = _Name;
        return _OptionLabel;
    return _OptionLabel;

Enjoy !!

Leave a comment

Filed under MS CRM 2011

Get Currency symbol based on currency ID

Today I saw one post in MS CRM development forum, where user needs to get currency symbol based on currency id, so thought to write this post to help. you can use below code to get currency symbol based on currency id

function GetCurrencySymbol() {

    var CurrencyID = Xrm.Page.getAttribute(“transactioncurrencyid”).getValue()[0].id;
    var context = Xrm.Page.context;
    var serverUrl = context.getServerUrl();
    var ODataPath = serverUrl + “/XRMServices/2011/OrganizationData.svc”;
    var retrieveCurrency= new XMLHttpRequest();“GET”, ODataPath + “/TransactionCurrencySet(guid'” + CurrencyID+ “‘)”, false);
    retrieveCurrency.setRequestHeader(“Accept”, “application/json”);
    retrieveCurrency.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
    retrieveCurrency.onreadystatechange = function() {

function retrieveCurrencyCallBack(retrieveCurrency) {
    if (retrieveCurrency.readyState == 4 /* complete */) {
        if (retrieveCurrency.status == 200) {

            var retrievedParent = this.parent.JSON.parse(retrieveCurrency.responseText).d;



 Enjoy !!!

Leave a comment

Filed under MS CRM 2011

Show MS CRM 2011 Optionset values in Dropdownlist in

Sometime customers have requirement to create MS CRM records through custom pages, and if we have optionset in that entity we might want to display optionset valeus in dropdownlist. So we can use below code to populate optionset values in dropdownlist.

public Dictionary<int, string> RetrieveOptionsetMetadata(IOrganizationService _iOgranizationService)

{ //Dictionary to store value and text

 Dictionary<int,string> _DropdownDatasource=newDictionary<int,string>();

 //Create request to fetch optionset

 RetrieveAttributeRequest _Request = new RetrieveAttributeRequest{

EntityLogicalName =“EntityName”,

LogicalName =“OptionsetFieldName”,

RetrieveAsIfPublished =true


 // Execute the request

 RetrieveAttributeResponse _Response =(RetrieveAttributeResponse)_iOgranizationService.Execute(_Request);

 PicklistAttributeMetadata _PicklistAttributeMetadata = (PicklistAttributeMetadata)_Response.AttributeMetadata;

 OptionMetadata[] optionList =_PicklistAttributeMetadata.OptionSet.Options.ToArray();

 foreach (OptionMetadata _Optionset in optionList) {

_DropdownDatasource.Add(int.Parse(_Optionset.Value.ToString()), _Optionset.Label.UserLocalizedLabel.Label);


 return _DropdownDatasource;


After that we can set datasource for dropdownlist like below

DropDownList1.DataSource = RetrieveOptionsetMetadata(_iOgranizationService);


Enjoy !!!

Leave a comment

Filed under MS CRM 2011