Friday, September 30, 2011

Search for KB Articles by Title in Microsoft Dynamics CRM 2011 Using .NET or Jscript

This illustration shows how to search for  Knowledge Base (KB) articles in Microsoft Dynamics CRM 2011  by title with SearchByTitleKbArticleRequest.   This example will be given in Jscript (SOAP) and in C# (.NET).
    Ok, here is what the code looks like!
    First in C#:

    SearchByTitleKbArticleRequest req = new SearchByTitleKbArticleRequest();
    req.SubjectId = new Guid("3B200FE0-6D96-4E7B-9DDF-FD1A6DF801E5");
    req.SearchText = "dolphins";
    QueryExpression qe = new QueryExpression();
    qe.EntityName = KbArticle.EntityLogicalName;
    qe.ColumnSet = new ColumnSet(true);
    req.QueryExpression = qe;
    
    SearchByTitleKbArticleResponse resp = (SearchByTitleKbArticleResponse)service.Execute(req);
    

    If you need help instantiating a service object in .NET within a plugin check out this post:
    http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

    Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

    Now in Jscript


    This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this posthttp://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

    if (typeof (SDK) == "undefined")
       { SDK = { __namespace: true }; }
           //This will establish a more unique namespace for functions in this library. This will reduce the 
           // potential for functions to be overwritten due to a duplicate name when the library is loaded.
           SDK.SAMPLES = {
               _getServerUrl: function () {
                   ///<summary>
                   /// Returns the URL for the SOAP endpoint using the context information available in the form
                   /// or HTML Web resource.
                   ///</summary>
                   var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                   var serverUrl = "";
                   if (typeof GetGlobalContext == "function") {
                       var context = GetGlobalContext();
                       serverUrl = context.getServerUrl();
                   }
                   else {
                       if (typeof Xrm.Page.context == "object") {
                             serverUrl = Xrm.Page.context.getServerUrl();
                       }
                       else
                       { throw new Error("Unable to access the server URL"); }
                       }
                      if (serverUrl.match(/\/$/)) {
                           serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                       } 
                       return serverUrl + OrgServicePath;
                   }, 
               SearchByTitleKbArticleRequest: function () {
                   var requestMain = ""
                   requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                   requestMain += "  <s:Body>";
                   requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                   requestMain += "      <request i:type=\"b:SearchByTitleKbArticleRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                   requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>SearchText</c:key>";
                   requestMain += "            <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">dolphins</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>SubjectId</c:key>";
                   requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">3b200fe0-6d96-4e7b-9ddf-fd1a6df801e5</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>UseInflection</c:key>";
                   requestMain += "            <c:value i:type=\"d:boolean\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">false</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>QueryExpression</c:key>";
                   requestMain += "            <c:value i:type=\"a:QueryExpression\">";
                   requestMain += "              <a:ColumnSet>";
                   requestMain += "                <a:AllColumns>true</a:AllColumns>";
                   requestMain += "                <a:Columns xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" />";
                   requestMain += "              </a:ColumnSet>";
                   requestMain += "              <a:Criteria>";
                   requestMain += "                <a:Conditions />";
                   requestMain += "                <a:FilterOperator>And</a:FilterOperator>";
                   requestMain += "                <a:Filters />";
                   requestMain += "              </a:Criteria>";
                   requestMain += "              <a:Distinct>false</a:Distinct>";
                   requestMain += "              <a:EntityName>kbarticle</a:EntityName>";
                   requestMain += "              <a:LinkEntities />";
                   requestMain += "              <a:Orders />";
                   requestMain += "              <a:PageInfo>";
                   requestMain += "                <a:Count>0</a:Count>";
                   requestMain += "                <a:PageNumber>0</a:PageNumber>";
                   requestMain += "                <a:PagingCookie i:nil=\"true\" />";
                   requestMain += "                <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>";
                   requestMain += "              </a:PageInfo>";
                   requestMain += "              <a:NoLock>false</a:NoLock>";
                   requestMain += "            </c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "        </a:Parameters>";
                   requestMain += "        <a:RequestId i:nil=\"true\" />";
                   requestMain += "        <a:RequestName>SearchByTitleKbArticle</a:RequestName>";
                   requestMain += "      </request>";
                   requestMain += "    </Execute>";
                   requestMain += "  </s:Body>";
                   requestMain += "</s:Envelope>";
                   var req = new XMLHttpRequest();
                   req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                   // Responses will return XML. It isn't possible to return JSON.
                   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");
                   var successCallback = null;
                   var errorCallback = null;
                   req.onreadystatechange = function () { SDK.SAMPLES.SearchByTitleKbArticleResponse(req, successCallback, errorCallback); };
                   req.send(requestMain);
               },
           SearchByTitleKbArticleResponse: function (req, successCallback, errorCallback) {
                   ///<summary>
                   /// Recieves the assign response
                   ///</summary>
                   ///<param name="req" Type="XMLHttpRequest">
                   /// The XMLHttpRequest response
                   ///</param>
                   ///<param name="successCallback" Type="Function">
                   /// The function to perform when an successfult response is returned.
                   /// For this message no data is returned so a success callback is not really necessary.
                   ///</param>
                   ///<param name="errorCallback" Type="Function">
                   /// The function to perform when an error is returned.
                   /// This function accepts a JScript error returned by the _getError function
                   ///</param>
                   if (req.readyState == 4) {
                   if (req.status == 200) {
                   if (successCallback != null)
                   { successCallback(); }
                   }
                   else {
                       errorCallback(SDK.SAMPLES._getError(req.responseXML));
                   }
               }
           },
           _getError: function (faultXml) {
               ///<summary>
               /// Parses the WCF fault returned in the event of an error.
               ///</summary>
               ///<param name="faultXml" Type="XML">
               /// The responseXML property of the XMLHttpRequest response.
               ///</param>
               var errorMessage = "Unknown Error (Unable to parse the fault)";
               if (typeof faultXml == "object") {
                   try {
                       var bodyNode = faultXml.firstChild.firstChild;
                       //Retrieve the fault node
                       for (var i = 0; i < bodyNode.childNodes.length; i++) {
                           var node = bodyNode.childNodes[i];
                           //NOTE: This comparison does not handle the case where the XML namespace changes
                           if ("s:Fault" == node.nodeName) {
                           for (var j = 0; j < node.childNodes.length; j++) {
                               var faultStringNode = node.childNodes[j];
                               if ("faultstring" == faultStringNode.nodeName) {
                                   errorMessage = faultStringNode.text;
                                   break;
                               }
                           }
                           break;
                       }
                   }
               }
               catch (e) { };
            }
            return new Error(errorMessage);
         },
     __namespace: true
    };
    
    

    To understand how to parse the response please review my post on using the DOM parser.
    Now you can call the SDK.SAMPLES.SearchByTitleKbArticleRequest  function from your form jscript handler.
    Thats all there is to it!
    -

    Thursday, September 29, 2011

    Search for KB Articles with Matching Keywords in Microsoft Dynamics CRM 2011 Using .NET or Jscript

    This illustration shows how to search for matching text in the body of a Knowledge Base (KB) article in Microsoft Dynamics CRM 2011 with SearchByKeyworksKbArticleRequest.   This example will be given in Jscript (SOAP) and in C# (.NET).
      Ok, here is what the code looks like!
      First in C#:

      SearchByKeywordsKbArticleRequest req = new SearchByKeywordsKbArticleRequest();
      req.SubjectId = new Guid("3B200FE0-6D96-4E7B-9DDF-FD1A6DF801E5");
      req.SearchText = "dolphins";
      QueryExpression qe = new QueryExpression();
      qe.EntityName = KbArticle.EntityLogicalName;
      qe.ColumnSet = new ColumnSet(true);
      req.QueryExpression = qe;
      
      SearchByKeywordsKbArticleResponse resp = (SearchByKeywordsKbArticleResponse)slos.Execute(req);
      
      

      If you need help instantiating a service object in .NET within a plugin check out this post:
      http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

      Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

      Now in Jscript


      This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this posthttp://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

      
      if (typeof (SDK) == "undefined")
         { SDK = { __namespace: true }; }
             //This will establish a more unique namespace for functions in this library. This will reduce the 
             // potential for functions to be overwritten due to a duplicate name when the library is loaded.
             SDK.SAMPLES = {
                 _getServerUrl: function () {
                     ///<summary>
                     /// Returns the URL for the SOAP endpoint using the context information available in the form
                     /// or HTML Web resource.
                     ///</summary>
                     var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                     var serverUrl = "";
                     if (typeof GetGlobalContext == "function") {
                         var context = GetGlobalContext();
                         serverUrl = context.getServerUrl();
                     }
                     else {
                         if (typeof Xrm.Page.context == "object") {
                               serverUrl = Xrm.Page.context.getServerUrl();
                         }
                         else
                         { throw new Error("Unable to access the server URL"); }
                         }
                        if (serverUrl.match(/\/$/)) {
                             serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                         } 
                         return serverUrl + OrgServicePath;
                     }, 
                 SearchByKeywordsKbArticleRequest: function () {
                     var requestMain = ""
                     requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                     requestMain += "  <s:Body>";
                     requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                     requestMain += "      <request i:type=\"b:SearchByKeywordsKbArticleRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                     requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>SearchText</c:key>";
                     requestMain += "            <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">dolphins</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>SubjectId</c:key>";
                     requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">3b200fe0-6d96-4e7b-9ddf-fd1a6df801e5</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>UseInflection</c:key>";
                     requestMain += "            <c:value i:type=\"d:boolean\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">false</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>QueryExpression</c:key>";
                     requestMain += "            <c:value i:type=\"a:QueryExpression\">";
                     requestMain += "              <a:ColumnSet>";
                     requestMain += "                <a:AllColumns>true</a:AllColumns>";
                     requestMain += "                <a:Columns xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" />";
                     requestMain += "              </a:ColumnSet>";
                     requestMain += "              <a:Criteria>";
                     requestMain += "                <a:Conditions />";
                     requestMain += "                <a:FilterOperator>And</a:FilterOperator>";
                     requestMain += "                <a:Filters />";
                     requestMain += "              </a:Criteria>";
                     requestMain += "              <a:Distinct>false</a:Distinct>";
                     requestMain += "              <a:EntityName>kbarticle</a:EntityName>";
                     requestMain += "              <a:LinkEntities />";
                     requestMain += "              <a:Orders />";
                     requestMain += "              <a:PageInfo>";
                     requestMain += "                <a:Count>0</a:Count>";
                     requestMain += "                <a:PageNumber>0</a:PageNumber>";
                     requestMain += "                <a:PagingCookie i:nil=\"true\" />";
                     requestMain += "                <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>";
                     requestMain += "              </a:PageInfo>";
                     requestMain += "              <a:NoLock>false</a:NoLock>";
                     requestMain += "            </c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "        </a:Parameters>";
                     requestMain += "        <a:RequestId i:nil=\"true\" />";
                     requestMain += "        <a:RequestName>SearchByKeywordsKbArticle</a:RequestName>";
                     requestMain += "      </request>";
                     requestMain += "    </Execute>";
                     requestMain += "  </s:Body>";
                     requestMain += "</s:Envelope>";
                     var req = new XMLHttpRequest();
                     req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                     // Responses will return XML. It isn't possible to return JSON.
                     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");
                     var successCallback = null;
                     var errorCallback = null;
                     req.onreadystatechange = function () { SDK.SAMPLES.SearchByKeywordsKbArticleResponse(req, successCallback, errorCallback); };
                     req.send(requestMain);
                 },
             SearchByKeywordsKbArticleResponse: function (req, successCallback, errorCallback) {
                     ///<summary>
                     /// Recieves the assign response
                     ///</summary>
                     ///<param name="req" Type="XMLHttpRequest">
                     /// The XMLHttpRequest response
                     ///</param>
                     ///<param name="successCallback" Type="Function">
                     /// The function to perform when an successfult response is returned.
                     /// For this message no data is returned so a success callback is not really necessary.
                     ///</param>
                     ///<param name="errorCallback" Type="Function">
                     /// The function to perform when an error is returned.
                     /// This function accepts a JScript error returned by the _getError function
                     ///</param>
                     if (req.readyState == 4) {
                     if (req.status == 200) {
                     if (successCallback != null)
                     { successCallback(); }
                     }
                     else {
                         errorCallback(SDK.SAMPLES._getError(req.responseXML));
                     }
                 }
             },
             _getError: function (faultXml) {
                 ///<summary>
                 /// Parses the WCF fault returned in the event of an error.
                 ///</summary>
                 ///<param name="faultXml" Type="XML">
                 /// The responseXML property of the XMLHttpRequest response.
                 ///</param>
                 var errorMessage = "Unknown Error (Unable to parse the fault)";
                 if (typeof faultXml == "object") {
                     try {
                         var bodyNode = faultXml.firstChild.firstChild;
                         //Retrieve the fault node
                         for (var i = 0; i < bodyNode.childNodes.length; i++) {
                             var node = bodyNode.childNodes[i];
                             //NOTE: This comparison does not handle the case where the XML namespace changes
                             if ("s:Fault" == node.nodeName) {
                             for (var j = 0; j < node.childNodes.length; j++) {
                                 var faultStringNode = node.childNodes[j];
                                 if ("faultstring" == faultStringNode.nodeName) {
                                     errorMessage = faultStringNode.text;
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 catch (e) { };
              }
              return new Error(errorMessage);
           },
       __namespace: true
      };
      
      

      To understand how to parse the response please review my post on using the DOM parser.
      Now you can call the SDK.SAMPLES.SearchByKeywordsKbArticleRequest  function from your form jscript handler.
      Thats all there is to it!
      -

      Wednesday, September 28, 2011

      Federated Active Directory Security Coming to Microsoft Dynamics CRM Online in Q4 2011

      UPDATED!  See Below.

      I have seen questions in the forums and blogs before regarding the possibility of federated active directory security coming to Microsoft Dynamics CRM Online for some time now, but it sounds now like Microsoft has committed to a date.  I first caught wind when I read this post (http://community.dynamics.com/product/crm/f/117/p/54548/98341.aspx), but figured it would still be awhile before it happened. 

      Then about a week ago, at the very first CRMUG meeting for the new Minnesota regional chapter, a Microsoft Employee that works specifically with CRM came out and said that it would be coming this year yet in Q4 along with a bunch of other feature enhancements that are going to be part of a first round of enhancements that is going to become a regular cycle as Microsoft is trying to move away from the big upgrades every 2 years or so in lieu of having more incremental enhancements on a more regular basis (maybe a couple times a year).

      How about that!  I am excited!  Look out SalesForce.  :)

      Update!  - I guess now it sounds like even though the linked "What's New!" document doesn't show it  http://bit.ly/uHWumO  It sounds like MSFT will be offering this to clients on a one by one basis starting in November.


      Tuesday, September 27, 2011

      Search for Matching Text in the Body of a KB Article in Microsoft Dynamics CRM 2011 Using .NET or Jscript

      This illustration shows how to search for matching text in the body of a Knowledge Base (KB) article in Microsoft Dynamics CRM 2011 with SearchByBodyKbArticleRequest.   This example will be given in Jscript (SOAP) and in C# (.NET).

      This call was another one of my mysteries from last week, http://mileyja.blogspot.com/2011/09/mysteries-of-crm-2011-sdk-part-1.html  , Mitch Milam (MVP) solved this one for me first.  I have embellished by adding a jscript example and playing with the C# syntax a bit to fit my style.  Props also go out to Jevjenij again as he also provided a comparable solution after the fact.

      Additionally, here are some of the notes Mitch left:
      • SubjectId is indeed required and must be the Id of a real Subject.
      • It looks like an ‘*’ is used for wildcard searches within the SearchText field. 
        • It would appear that without the wildcard, only whole words are considered.
      •  The QueryExpression seems to be used to determine the columns for the resultset. 
        • You may wish to make a note of that. It is very confusing otherwise to have a SearchText field and a QueryExpression.
        •  I have not attempted to add a FilterExpression but I suspect it will not work.
      •  UseInflection is not required - but it does indeed work just the way the documentation says.
      Ok, here is what the code looks like!
      First in C#:

      SearchByBodyKbArticleRequest req = new SearchByBodyKbArticleRequest();
      req.SubjectId = new Guid("3B200FE0-6D96-4E7B-9DDF-FD1A6DF801E5");
      req.SearchText = "dolphins";
      QueryExpression qe = new QueryExpression();
      qe.EntityName = KbArticle.EntityLogicalName;
      qe.ColumnSet = new ColumnSet(true);
      req.QueryExpression = qe;
      
      SearchByBodyKbArticleResponse resp = (SearchByBodyKbArticleResponse)slos.Execute(req);
      
      

      If you need help instantiating a service object in .NET within a plugin check out this post:
      http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

      Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

      Now in Jscript


      This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this posthttp://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

      
      if (typeof (SDK) == "undefined")
         { SDK = { __namespace: true }; }
             //This will establish a more unique namespace for functions in this library. This will reduce the 
             // potential for functions to be overwritten due to a duplicate name when the library is loaded.
             SDK.SAMPLES = {
                 _getServerUrl: function () {
                     ///<summary>
                     /// Returns the URL for the SOAP endpoint using the context information available in the form
                     /// or HTML Web resource.
                     ///</summary>
                     var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                     var serverUrl = "";
                     if (typeof GetGlobalContext == "function") {
                         var context = GetGlobalContext();
                         serverUrl = context.getServerUrl();
                     }
                     else {
                         if (typeof Xrm.Page.context == "object") {
                               serverUrl = Xrm.Page.context.getServerUrl();
                         }
                         else
                         { throw new Error("Unable to access the server URL"); }
                         }
                        if (serverUrl.match(/\/$/)) {
                             serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                         } 
                         return serverUrl + OrgServicePath;
                     }, 
                 SearchByBodyKbArticleRequest: function () {
                     var requestMain = ""
                     requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                     requestMain += "  <s:Body>";
                     requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                     requestMain += "      <request i:type=\"b:SearchByBodyKbArticleRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                     requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>SearchText</c:key>";
                     requestMain += "            <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">dolphins</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>SubjectId</c:key>";
                     requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">3b200fe0-6d96-4e7b-9ddf-fd1a6df801e5</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>UseInflection</c:key>";
                     requestMain += "            <c:value i:type=\"d:boolean\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">false</c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>QueryExpression</c:key>";
                     requestMain += "            <c:value i:type=\"a:QueryExpression\">";
                     requestMain += "              <a:ColumnSet>";
                     requestMain += "                <a:AllColumns>true</a:AllColumns>";
                     requestMain += "                <a:Columns xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" />";
                     requestMain += "              </a:ColumnSet>";
                     requestMain += "              <a:Criteria>";
                     requestMain += "                <a:Conditions />";
                     requestMain += "                <a:FilterOperator>And</a:FilterOperator>";
                     requestMain += "                <a:Filters />";
                     requestMain += "              </a:Criteria>";
                     requestMain += "              <a:Distinct>false</a:Distinct>";
                     requestMain += "              <a:EntityName>kbarticle</a:EntityName>";
                     requestMain += "              <a:LinkEntities />";
                     requestMain += "              <a:Orders />";
                     requestMain += "              <a:PageInfo>";
                     requestMain += "                <a:Count>0</a:Count>";
                     requestMain += "                <a:PageNumber>0</a:PageNumber>";
                     requestMain += "                <a:PagingCookie i:nil=\"true\" />";
                     requestMain += "                <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>";
                     requestMain += "              </a:PageInfo>";
                     requestMain += "              <a:NoLock>false</a:NoLock>";
                     requestMain += "            </c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "        </a:Parameters>";
                     requestMain += "        <a:RequestId i:nil=\"true\" />";
                     requestMain += "        <a:RequestName>SearchByBodyKbArticle</a:RequestName>";
                     requestMain += "      </request>";
                     requestMain += "    </Execute>";
                     requestMain += "  </s:Body>";
                     requestMain += "</s:Envelope>";
                     var req = new XMLHttpRequest();
                     req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                     // Responses will return XML. It isn't possible to return JSON.
                     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");
                     var successCallback = null;
                     var errorCallback = null;
                     req.onreadystatechange = function () { SDK.SAMPLES.SearchByBodyKbArticleResponse(req, successCallback, errorCallback); };
                     req.send(requestMain);
                 },
             SearchByBodyKbArticleResponse: function (req, successCallback, errorCallback) {
                     ///<summary>
                     /// Recieves the assign response
                     ///</summary>
                     ///<param name="req" Type="XMLHttpRequest">
                     /// The XMLHttpRequest response
                     ///</param>
                     ///<param name="successCallback" Type="Function">
                     /// The function to perform when an successfult response is returned.
                     /// For this message no data is returned so a success callback is not really necessary.
                     ///</param>
                     ///<param name="errorCallback" Type="Function">
                     /// The function to perform when an error is returned.
                     /// This function accepts a JScript error returned by the _getError function
                     ///</param>
                     if (req.readyState == 4) {
                     if (req.status == 200) {
                     if (successCallback != null)
                     { successCallback(); }
                     }
                     else {
                         errorCallback(SDK.SAMPLES._getError(req.responseXML));
                     }
                 }
             },
             _getError: function (faultXml) {
                 ///<summary>
                 /// Parses the WCF fault returned in the event of an error.
                 ///</summary>
                 ///<param name="faultXml" Type="XML">
                 /// The responseXML property of the XMLHttpRequest response.
                 ///</param>
                 var errorMessage = "Unknown Error (Unable to parse the fault)";
                 if (typeof faultXml == "object") {
                     try {
                         var bodyNode = faultXml.firstChild.firstChild;
                         //Retrieve the fault node
                         for (var i = 0; i < bodyNode.childNodes.length; i++) {
                             var node = bodyNode.childNodes[i];
                             //NOTE: This comparison does not handle the case where the XML namespace changes
                             if ("s:Fault" == node.nodeName) {
                             for (var j = 0; j < node.childNodes.length; j++) {
                                 var faultStringNode = node.childNodes[j];
                                 if ("faultstring" == faultStringNode.nodeName) {
                                     errorMessage = faultStringNode.text;
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 catch (e) { };
              }
              return new Error(errorMessage);
           },
       __namespace: true
      };
      
      


      To understand how to parse the response please review my post on using the DOM parser.
      Now you can call the SDK.SAMPLES.SearchByBodyKbArticleRequest  function from your form jscript handler.
      Thats all there is to it!


      1. I hope this helps!

      Monday, September 26, 2011

      Remove the Manager from a User Using .NET or Jscript in Microsoft Dynamics CRM 2011 Using RemoveParentRequest

      This illustration shows how to remove the manager from a user (sytemuser) entity  in Microsoft Dynamics CRM 2011 with RemoveParentRequest.   This example will be given in Jscript (SOAP) and in C# (.NET).

      This call was one of my mysteries from last week, http://mileyja.blogspot.com/2011/09/mysteries-of-crm-2011-sdk-part-1.html  , Jevgenij solved this one for me by informing me that this call is specific to the user entity and is for removing the user's manager.  I was trying to use this call, unsuccessfully, to remove a parent account from account entity.

      Ok, here is what the code looks like!
      First in C#:

      RemoveParentRequest req = new RemoveParentRequest();
      req.Target = new EntityReference("systemuser", new Guid("822C854A-EADA-E011-8D41-1CC1DEE8EA01"));
      RemoveParentResponse resp = (RemoveParentResponse)slos.Execute(req);
      

      If you need help instantiating a service object in .NET within a plugin check out this post:
      http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

      Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

      Now in Jscript


      This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this posthttp://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

      if (typeof (SDK) == "undefined")
         { SDK = { __namespace: true }; }
             //This will establish a more unique namespace for functions in this library. This will reduce the 
             // potential for functions to be overwritten due to a duplicate name when the library is loaded.
             SDK.SAMPLES = {
                 _getServerUrl: function () {
                     ///<summary>
                     /// Returns the URL for the SOAP endpoint using the context information available in the form
                     /// or HTML Web resource.
                     ///</summary>
                     var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                     var serverUrl = "";
                     if (typeof GetGlobalContext == "function") {
                         var context = GetGlobalContext();
                         serverUrl = context.getServerUrl();
                     }
                     else {
                         if (typeof Xrm.Page.context == "object") {
                               serverUrl = Xrm.Page.context.getServerUrl();
                         }
                         else
                         { throw new Error("Unable to access the server URL"); }
                         }
                        if (serverUrl.match(/\/$/)) {
                             serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                         } 
                         return serverUrl + OrgServicePath;
                     }, 
                 RemoveParentRequest: function () {
                     var requestMain = ""
                     requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                     requestMain += "  <s:Body>";
                     requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                     requestMain += "      <request i:type=\"b:RemoveParentRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                     requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>Target</c:key>";
                     requestMain += "            <c:value i:type=\"a:EntityReference\">";
                     requestMain += "              <a:Id>822c854a-eada-e011-8d41-1cc1dee8ea01</a:Id>";
                     requestMain += "              <a:LogicalName>systemuser</a:LogicalName>";
                     requestMain += "              <a:Name i:nil=\"true\" />";
                     requestMain += "            </c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "        </a:Parameters>";
                     requestMain += "        <a:RequestId i:nil=\"true\" />";
                     requestMain += "        <a:RequestName>RemoveParent</a:RequestName>";
                     requestMain += "      </request>";
                     requestMain += "    </Execute>";
                     requestMain += "  </s:Body>";
                     requestMain += "</s:Envelope>";
                     var req = new XMLHttpRequest();
                     req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                     // Responses will return XML. It isn't possible to return JSON.
                     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");
                     var successCallback = null;
                     var errorCallback = null;
                     req.onreadystatechange = function () { SDK.SAMPLES.RemoveParentResponse(req, successCallback, errorCallback); };
                     req.send(requestMain);
                 },
             RemoveParentResponse: function (req, successCallback, errorCallback) {
                     ///<summary>
                     /// Recieves the assign response
                     ///</summary>
                     ///<param name="req" Type="XMLHttpRequest">
                     /// The XMLHttpRequest response
                     ///</param>
                     ///<param name="successCallback" Type="Function">
                     /// The function to perform when an successfult response is returned.
                     /// For this message no data is returned so a success callback is not really necessary.
                     ///</param>
                     ///<param name="errorCallback" Type="Function">
                     /// The function to perform when an error is returned.
                     /// This function accepts a JScript error returned by the _getError function
                     ///</param>
                     if (req.readyState == 4) {
                     if (req.status == 200) {
                     if (successCallback != null)
                     { successCallback(); }
                     }
                     else {
                         errorCallback(SDK.SAMPLES._getError(req.responseXML));
                     }
                 }
             },
             _getError: function (faultXml) {
                 ///<summary>
                 /// Parses the WCF fault returned in the event of an error.
                 ///</summary>
                 ///<param name="faultXml" Type="XML">
                 /// The responseXML property of the XMLHttpRequest response.
                 ///</param>
                 var errorMessage = "Unknown Error (Unable to parse the fault)";
                 if (typeof faultXml == "object") {
                     try {
                         var bodyNode = faultXml.firstChild.firstChild;
                         //Retrieve the fault node
                         for (var i = 0; i < bodyNode.childNodes.length; i++) {
                             var node = bodyNode.childNodes[i];
                             //NOTE: This comparison does not handle the case where the XML namespace changes
                             if ("s:Fault" == node.nodeName) {
                             for (var j = 0; j < node.childNodes.length; j++) {
                                 var faultStringNode = node.childNodes[j];
                                 if ("faultstring" == faultStringNode.nodeName) {
                                     errorMessage = faultStringNode.text;
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 catch (e) { };
              }
              return new Error(errorMessage);
           },
       __namespace: true
      };
      
      


      To understand how to parse the response please review my post on using the DOM parser.
      Now you can call the SDK.SAMPLES.RemoveParentRequest  function from your form jscript handler.
      Thats all there is to it!

      I hope this helps!

      Friday, September 23, 2011

      Mysteries of the Microsoft Dynamics CRM 2011 SDK - Part 1

      I know some of you have been following my journey through the SDK this year.  Over that period I have run into a few messages I have tried to implement successfully but they have eluded me.  Not just because I can't figure out how to implement them, but because they just don't seem to make a whole lot of sense.  Here are a few that I just don't get as of right now.  Your input would be greatly appreciated as the MSDN references for these requests are not complete and I can't find many other instances where people are using these requests and I am guessing it's for the same reasons I am laying out below.

      Mystery Number 1 - RemoveParentRequest - Solved!, Thanks Jevgenij


      What I Would Expect to Happen:
      This seems to me like a pretty straight forward request.  I could use to to remove a parent account from an account or something to that effect.  It pretty much only has one member that isn't on every other request that I can see and that is Target which obviously takes an EntityReference.  I can just specify my entity that should have it's parent removed.


      What's Just Seems Wrong:
      It throws an error about not being able to find a valid SystemUser with the Guid I specified in my "account" EntityReference.  I am not really sure what they are looking for here since there is already a requests out there to remove members from teams and such.

      Update: Thanks to Jevgenij, we now have our answer:  Check it out at http://mileyja.blogspot.com/2011/09/remove-manager-from-user-net-or-jscript.html

      What still feels wrong:  
      I feel like this call should be named RemoveManagerRequest or that it should work for more scenarios like the one where I was trying to remove the parent account from another account.  It's too generic because RemoveParentRequest doesn't imply that the call is entity specific; also it is further confusing because it asks for an EntityReference and the member is just named Target, which could be any entity type, where this should be just a Guid member called UserId maybe which would more descriptive.

      Maybe they meant for this call to cover more scenarios but maybe those other scenarios were just never implemented.


      Mystery Number 2 -  Any of the Search KB Article Requests (I.E. SearchByBodyKBArticleRequest) - Solved!  Thanks Mitch Milam!


      What I Would Expect to Happen:
      Ooh ooh.... This is great.  I can specify words and phrases that will be used to scour all of my KB articles to find the ones that contain those words.  This is great, it has all the properties I need.  I can specify my SearchText as a string, so we can look for things like "dolphins" or "snicker pops" or even "Jim Glass likes to eat clam chowder at Fisherman's Warf".  I can specify a SubjectId to narrow things down even further, this is awesome.


      What's Just Seems Wrong:


      What's this additional QueryExpression stuff that is required.  I understand QueryExpression syntax and such, but I don't know why I need it here considering we have all these great members on the request class already that specify everything I should need to search for a KB article.  I just don't know what to put there.  Also that SubjectId thing is required so you can't really search all the KB articles in one pop, you have to do it by subject, but never mind that right now considering I can't get it to work because I can't figure out what they want for the QueryExpression. :(

      Update: 

      Mitch Milam (MVP) provided the answer for this item first, followed by Jevgenij. Check out the call example at:http://mileyja.blogspot.com/2011/09/search-for-matching-text-in-body-of-kb.html

      Aftermath: 


      This one was me just me not understanding  the QueryExpression necessity with this call.  It made perfect sense to me once it was explained to me and was, in the end, just a matter of lack of documentation.

      Mystery Number 3 -  RetrieveUserIdByExternalIdRequest


      What I Would Expect to Happen:
      This is for CRM Online and is a call that is part of the discovery service.  The explanation given in TechNet is pretty straight forward:

      "Contains the data needed to retrieve the Microsoft Dynamics CRM Online system user ID that is associated with a given Windows Live ID."

      So this means that I can specify my Windows Live Id and this call will bounce it off of an organization in CRM Online and give me the associated User Id in the system.


      What's Just Seems Wrong:


      Nothing useful comes back, there are no errors, just a relatively empty, but valid, response envelope that doesn't have the User Id I requested.


      In conclusion, there are some issues with the SDK that still make it an evolving product it seems, if not only in documentation.  These SDK requests may be completely valid and I just might not be able to find good enough documentation to be able to use them effectively.

      Thoughts?

      -


      Thursday, September 22, 2011

      What's New In Update Rollup 4 for Microsoft Dynamics CRM 2011

      Microsoft Dynamics CRM 2011 Update Rollup 4 was just released.  It's build number is: 5.0.9688.1450

      It has not manually required hotfixes and it obviously also has the fixes included from all previous rollups.

      You can download it here:
      http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27554

      The new stuff is below: taken from http://support.microsoft.com/default.aspx?kbid=2556167

      Update Rollup 4 contains the following additional fixes. One of these fixes is documented in a separate Knowledge Base article.
      • You cannot open Microsoft Dynamics CRM after you install Microsoft Dynamics CRM 2011 in an environment that has Microsoft .NET Framework 4.5 Prerelease installed. 
      • When you try to install SRS Reporting Extensions, you receive the following error message:
        Check ReportServerValidator : Failure: Unable to validate SQL Server Reporting Services Report Server installation.
        Please check that it is correctly installed on the local machine.
         
      • When you access Microsoft Dynamics CRM 2011 from a URL, an _hc query parameter is added to hide the ribbons in Microsoft Dynamics CRM 2011. This parameter uses Boolean string values, such as true and false. 
      • If you hide the Include group on the ribbon of an appointment and phone call entity, you receive the following error message:  
        Script error on page.
        This problem occurs when you use a non-English (United States) version of Microsoft Dynamics CRM 2011 or a language pack with a display language that is not English. 
      • Assume that you create an account name that contains additional spaces for a new account in Microsoft Dynamics CRM 2011. When you click To Opportunity in the Convert Activity group in a corresponding activity, you receive the following error message: 
        You must save the changes before you can convert this activity.
         
      • When you try to delete an activity from a newly created Activity view, you receive the following error message: 
        Record is unavailable. 
      • Assume that you open a service activity, click Schedule, and then click Find Available Times. In this situation, Microsoft Dynamics CRM 2011 displays incorrect available times.  
      • Consider the following scenario: 
        • You create two unmanaged solutions.
        • You export the solutions as managed. 
        • You import the managed solutions. 
        • You import the first solution again by using the Overwrite setting.
        In this scenario, an unmanaged layer is generated and some original fields are missing.
      • When you use the Maintain method to re-import a solution, you receive an error message that resembles the following:
        Role With Id = 627090ff-40a3-4053-8790-584edc5be201 Does Not Exist.
      • When you try to expand duplicate appointments in the Service Calendar in Microsoft Dynamics CRM 2011, a script error occurs. 
      • Assume that Microsoft Dynamics CRM 2011 contains an entity that has many relationships. When you try to change a lookup field of the entity, you receive the following error message: 
        An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organizations Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
      • If a URL text box contains JavaScript code that is not validated, JavaScript may unexpectedly run.
        After you apply this hotfix, the target URL will be validated as expected. 
      • Assume that you enable the Auditing setting for processes. When you start, deactivate, or update a workflow, you receive the following error message: 
        An error has occurred. Try this action again.
      • When duplicate detection is enabled, you cannot convert a lead to an opportunity. 
      • Assume that you use a number format setting other than English (United States). When you run the Close as Won function on an opportunity, the estimated value is multiplied by 10,000.
      • If you register a plug-in assembly against an incident entity in the post-operation stage, the plug-in assembly is unexpectedly executed outside the transaction. 
      • Consider the following scenario: 
        • You create two accounts. 
        • You select the second account, and then click Connections
        • To create a new connection, you click Connect, select the first account in the Name field, and then click Save and Close.
        • You back up the organization database, and then restore it to a new database. 
        • You start the Deployment Wizard, and then import the restored database. 
        • In Internet Explorer, you browse the imported organization, and then open the second account. 
        • You open a connection in the account record. 
        In this scenario, you receive an error message that resembles the following: 
        CrmException: businessunit With Id = 0b603c1a-5940-e011-bfeb-00155d540dbb Does Not Exist.
      • Records are visible regardless of the security role. This problem occurs because of cascading in the POA table. 
      • Consider the following scenario: 
        • You start the Microsoft Dynamics CRM 2011 client for Microsoft Office Outlook.
        • You take the Microsoft Dynamics CRM 2011 client for Outlook offline. 
        • You click Workplace, and then click Reports.
        • You run the Neglected Accounts report that has a zero value set in the Minimum Days Neglected parameter.
        • You click the chart to drill through to the child report.
        In this scenario, you receive the following error message: 
        Invalid Argument.
      • Assume that you have a report that contains a prefilter. If you import the report two times, the prefilter does not work in the report. 
      • By default, the maximum length of an absolute URL for a Microsoft SharePoint document location is set to 2,000 characters. However, the URL cannot exceed 256 characters. After you apply this hotfix, the character data type will be changed to nvarchar(max). 
      • When you use a custom report that contains a primary entity and a secondary entity, the Date and Time columns are displayed in an incorrect format. Additionally, columns that should only display the date, display the date and the time. 
      • Assume that you use a POP3 email account. When an email message is sent from an account whose display name contains parenthesis, you cannot receive the email message in Microsoft Dynamics CRM 2011. 
      • When you use the CrmSvcUtil.exe tool in a Microsoft Dynamics CRM 2011 environment that is configured for Internet-facing Deployment (IFD), you receive the following error message: 
        The user authentication failed! Enable tracing and view the trace files for more information.
      • Assume that you create a task in Outlook and track the task in Microsoft Dynamics CRM 2011. When you synchronize the task with Microsoft Dynamics CRM, the due date for the task is changed incorrectly to a previous due date. 
      • Assume that you are in a child business unit. If you create a solution, you cannot add security roles to the solution. In this situation, the only roles that can be selected for the solution are the roles in your business unit. However, the roles that can be added are the roles in the root business unit. 
      • To correct Spanish translation issues, change the field label of the Business Recommended field. 
      • Some Estonian language translations are incorrect in Microsoft Dynamics CRM 2011. 
      • The "Accounts: No orders in last 6 months" account view incorrectly displays accounts that have orders which were added in the last six months. 
      • Assume that you install Update Rollup 3 for Microsoft Dynamics CRM 2011. You start Outlook, and then try to go offline. In this situation, Outlook cannot go offline. Additionally, the following error message is logged in the platform trace: 
        Exception happened Database having current version is not upgradeable.
      • Incorrect icons are displayed for custom entities in the Microsoft Dynamics CRM 2011 client for Outlook. 
      • When you run a quick campaign in the Microsoft Dynamics CRM 2011 client for Outlook, you receive the following error message: 
        System.NullReferenceException was unhandled by user code.
      • When you try to add an email message activity to a custom entity in the Microsoft Dynamics CRM 2011 client for Outlook, a script error occurs. 
      • When you add the Actual End field to an email message form and then set the format to Date and Time, the time value is displayed in UTC format instead of your local time zone. 
      • When you use the Mail Merge function to send an email message that has an attachment in the Microsoft Dynamics CRM 2011 client for Outlook, the full location of the attached file is displayed in the file name of the attachment. 
      • Assume that you create a new email message that has some CRM fields specified in the Microsoft Dynamics CRM 2011 client for Outlook. When you click Save in the Microsoft Dynamics CRM 2011 client for Outlook, the values of the CRM fields are not saved. 
      • If you enable folder redirection for a user in Microsoft Dynamics CRM 2011, the synchronization process fails in the Microsoft Dynamics CRM 2011 client for Outlook. Additionally, the following error message is logged in the platform trace: 
        Crm Exception: Message: SQL CE Database file is being used by a different process, ErrorCode: -2147220970, InnerException: There is a file sharing violation. A different process might be using the file.
         
      • When you perform a bulk delete operation for business units in Microsoft Dynamics CRM 2011, you receive an error message that resembles the following: 
        CrmException: businessunit With Id = 7a60b6da-8bbc-e011-bd33-00155d9c4f08 Does Not Exist.
      • Assume that a server is running an older version of Microsoft Dynamics CRM 2011 than a client. The server also has a larger attribute length than the client. When you go offline in the Microsoft Dynamics CRM 2011 client for Outlook, you receive the following error message: 
        OfflineMetadataVersion of is different than ServerMetadataVersion.
      • When you click Audit History in the Microsoft Dynamics CRM 2011 Web client, you receive the following error message:
        An unexpected error occurred.
        This problem occurs when the system date is formatted in non-United States English. 
      • Consider the following scenario: 
        • You create an account record, and then create a second identical account record.
        • When you save the second account record, the Duplicates Detected dialog box appears. You click Save Record to create duplicate records. 
        • You create a new duplicate detection job to check for duplicates, and then execute the job.
        • You open the duplicate detection job, and then click View Duplicates.
        • You merge duplicate records.
        In this scenario, an unhandled exception error occurs. 
      • Assume that you enable the audit feature for contact entities. After you change the status of a contact, the Currency field is displayed incorrectly in the audit history. 
      • All email messages that are generated by the Mail Merge function have the same regarding contact. 
      • When you export data from a Report Wizard report to a Microsoft Office Excel worksheet, you cannot change the format of the currency, date, or number fields in the Excel worksheet. 
      • If you use a number and currency format other than English (United States) in the system settings, the monetary values are displayed incorrectly in the grids in the Microsoft Dynamics CRM 2011 Web client. The monetary values are also displayed incorrectly in the grids and reading panes in the Microsoft Dynamics CRM 2011 client for Outlook. 
      • When you try to delete a managed solution that contains a custom activity based on another managed solution, you receive the following error message: 
        Cannot Delete Field. Only customer fields can be deleted.
      • When you import an updated managed solution to an organization that has a language pack enabled, you receive the following error message:
        Violation of UNIQUE KEY constraint.
      • When you add users in a multiple site domain, and then click Save, you experience slow performance. 
      • When you assign accounts to another Microsoft Dynamics CRM 2011 user, an unexpected error occurs. This problem occurs when the accounts have recurring appointment activities. 
      • Assume that a managed solution contains components with managed properties that restrict users from changing the solution in Microsoft Dynamics CRM 2011. When you import updates to the solution, an error occurs.  
      • When you use the FetchXML function to return the sum total of a currency field, the returned value is incorrect. This problem occurs when you use a currency that differs from the default currency.
      • If the EnableRetrieveMultipleOptimization registry key is set to 2, users who do not have System Administrator roles cannot see a list of reports. 
      • The asynchronous service crashes because the OperationType field is null. In this situation, the following error message is logged in the Application Event Log.
        System.InvalidCastException:Specified cast is not valid.
      • Assume that you create and enable a workflow that is registered on an order.
        When you install Microsoft Dynamics CRM Connector for Microsoft Dynamics GP, and then submit an order from Microsoft Dynamics GP to Microsoft Dynamics CRM, the order does not integrate as expected.
        Additionally, when you write a console application to execute the CompoundCreate process on the order, the CompoundCreate request fails.
        In both situations, you receive the following error message: 
        Crm Exception: Message: An unexpected error occurred., ErrorCode: -2147220970, InnerException: System.Runtime.Serialization.SerializationException: Type 'Microsoft.Crm.Sdk.DynamicEntity[]' with data contract name 'ArrayOfDynamicEntity:http://schemas.datacontract.org/2004/07/Microsoft.Crm.Sdk' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
      • Assume that you apply Microsoft Dynamics CRM 2011 Update Rollup 1 or Microsoft Dynamics CRM 2011 Update Rollup 2. When you try to set the state of a price level object by using theSetStateDynamicEntityRequest process in Microsoft Dynamics CRM 4.0 (2007) Endpoint, you receive the following error message:
        <error>
        <code>0x80048408</code>
        <description>-1 is not a valid state code on pricelevel. </description>
        <type>Platform</type>
        </error>
           
      • When you add a URL to a SiteMap Area or a SubArea that contains QueryString parameters in Microsoft Dynamics CRM 2011, the URL is displayed incorrectly. 
      • Assume that two managed solutions contain multiple workflows that have use the samesdkmessageprocessing step in Microsoft Dynamics CRM 2011. When you import one of the managed solutions, you receive the following error message:
        A managed solution cannot overwrite SdkMessageProcessingStep component with Id=5b73086f-9843-e011-b634-00155da9dd03 which has an unmanaged base instance. 
      • After you update a workflow from Microsoft Dynamics CRM 4.0 to Microsoft Dynamics CRM 2011, the workflow does not run as expected. Additionally, you receive the following platform trace error message:
        Crm Exception: Message: Expected non-empty Guid., ErrorCode: -2147220989, InnerException: System.ArgumentException: Expected non-empty Guid
        Parameter name: id
      • The DoNotBulkPostalMail field in the Contact entity cannot be edited. Additionally, the ContactDoNotBulkPostalMail field is not listed when you design the entity form. 
      • When multiple currencies exist in a transaction, the exchange rates are applied to records incorrectly. The first exchange rate that is retrieved from the first currency is applied to all records in the transaction. 
      • Assume that you upgrade to Microsoft Dynamics CRM 2011. When you try to save new Microsoft Dynamics CRM entity records for entities that have monetary fields in the forms, an error occurs. Additionally, an application error is logged in the Application Event Viewer. 
      • 2616319  An error occurs when you run the Synchronize with CRM function in the Microsoft Dynamics CRM 2011 client for Outlook with folder redirection enabled.