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: http://msdn.microsoft.com/en-us/library/gg309589.aspx 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: http://msdn.microsoft.com/en-us/library/gg490659.aspx

  • 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 : http://msdn.microsoft.com/en-us/library/gg309471.aspx

  • 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 : http://msdn.microsoft.com/en-us/library/gg334576.aspx 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 : http://msdn.microsoft.com/en-us/library/gg309608.aspx

  • How can we use auditing in MS CRM 2011.

–         Auditing can be configured easily through CRM UI. Refer: http://www.avanadeblog.com/xrm/2010/09/crm-2011-feature-of-the-week-9132010-auditing.html for more details on auditing.

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

Enjoy!!!

Advertisement

3 Comments

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=\”http://schemas.xmlsoap.org/soap/envelope/\“>” +
    “<s:Body>” +
    “<Execute xmlns=\”http://schemas.microsoft.com/xrm/2011/Contracts/Services\” xmlns:i=\”http://www.w3.org/2001/XMLSchema-instance\“>” +
    “<request i:type=\”a:RetrieveOptionSetRequest\” xmlns:a=\”http://schemas.microsoft.com/xrm/2011/Contracts\“>” +
    “<a:Parameters xmlns:b=\”http://schemas.datacontract.org/2004/07/System.Collections.Generic\“>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>MetadataId</b:key>” +
    “<b:value i:type=\”c:guid\” xmlns:c=\”http://schemas.microsoft.com/2003/10/Serialization/\”>”+MetadaID+”</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>RetrieveAsIfPublished</b:key>” +
    “<b:value i:type=\”c:boolean\” xmlns:c=\”http://www.w3.org/2001/XMLSchema\”>false</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “<a:KeyValuePairOfstringanyType>” +
    “<b:key>Name</b:key>” +
    “<b:value i:type=\”c:string\” xmlns:c=\”http://www.w3.org/2001/XMLSchema\”>OptionsetName</b:value>” +
    “</a:KeyValuePairOfstringanyType>” +
    “</a:Parameters>” +
    “<a:RequestId i:nil=\”true\” />” +
    “<a:RequestName>RetrieveOptionSet</a:RequestName>” +
    “</request></Execute></s:Body></s:Envelope>”;
    var req = new XMLHttpRequest();
    req.open(“POST”, _ServerURL, false)
    req.setRequestHeader(“Accept”, “application/xml, text/xml, */*”);
    req.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
    req.setRequestHeader(“SOAPAction”, “http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute“);
    req.send(xmlrequest);
    var resultXml = req.responseXML;

    var errorCount = resultXml.selectNodes(‘//error’).length;
    if (errorCount != 0) {
        var msg = resultXml.selectSingleNode(‘//description’).nodeTypedValue;
        alert(msg);
    }
    else {
       
        var oXmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
        oXmlDoc.async = false;
        oXmlDoc.loadXML(resultXml.xml);
        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;
                break;
            }
        }
        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() {

if(Xrm.Page.getAttribute(“transactioncurrencyid”).getValue()!=null)
{
    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();
    retrieveCurrency.open(“GET”, ODataPath + “/TransactionCurrencySet(guid'” + CurrencyID+ “‘)”, false);
    retrieveCurrency.setRequestHeader(“Accept”, “application/json”);
    retrieveCurrency.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
    retrieveCurrency.onreadystatechange = function() {
        retrieveCurrencyCallBack(this);
    };
    retrieveCurrency.send();
    }

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

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

                    alert(retrievedParent.CurrencySymbol);

}
 
}}

 Enjoy !!!

Leave a comment

Filed under MS CRM 2011

Show MS CRM 2011 Optionset values in Dropdownlist in Asp.net

Sometime customers have requirement to create MS CRM records through custom asp.net 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);

DropDownList1.DataBind();

Enjoy !!!

Leave a comment

Filed under MS CRM 2011