IMPORTANT: You should not use this library for new projects! If you have used this library, you should migrate your code to use the Web API. This library uses the deprecated 2011 Organization Service SOAP Endpoint, which will be removed in a future release after v9.x.

C# (475.9 KB)
4.9 Star
5,628 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Problems with update (April 2017)
    2 Posts | Last post May 16, 2017
    • Hi,
      We have recently updated our Dynamics 365 CRM to version and have been experiencing problems with Sdk.Soap.js.
      Function: Sdk.jQ.retrieveMultiple'.
      When retrieving entities with all-attributes=true, the following error occurs: "Value property must be a string". 
      After some debugging, it appears in our case this is because of attribute 'owningbusinessunit', but possibly 'owninguser' as well.
      I have traced it back to the following SOAP XML returned from the web service:
      If you examine the XML, you can see that 'owningbusinessunit' is given as  an entityreference-attribute without a name ("<a:Name i:nil="true"/>").
      Then again as 'FormattedValues', with as value "<b:value i:nil="true"/>".
      My guess is that Sdk.Soap.js presumed that this value is always filled with a string value and this used to be the case. But it seems now with this update that might have changed.
      Thank you for reading and I hope a hotfix can be made to support this new version of Dynamics 365 so we can continue using this awesome library.
      With kind regards,
      Richard Bos
    • Richard -
      All the errors returned by the library are pretty explicit and I couldn't find one within Sdk.Soap.vsdoc.js which simply said "Value property must be a string".
      There are some similar ones, but they always specify which class the error comes from. For example:
      throw new Error("Sdk.FormattedValue Value property must be a string."); 
      throw new Error("Sdk.Guid value property must be a String representation of a Guid value."); 
      throw new Error("Sdk.String value property must be a String."); 
      Are you sure there wasn't more to the error?
      Depending on where the error occurs, I expect that the fix would be to identify which validation code is throwing the error and modify it so that it recognizes that the null value returned is null and route the logic to set the value to null. I expect you will need to change something that looks like the following but the value is something other than null or a string.
         if (value == null || typeof value == "string") { 
         else { 
          throw new Error("Sdk.String value property must be a String."); 
      It is also a good idea to avoid using all-attributes=true and only get the attributes you really need.
      Finally, with the deprecation of the SOAP endpoint in favor of the Web API we aren't doing testing or maintenance on this sample.
      Now that you are on version 8.2, you should consider migrating over to the Web API.
      Some helpful libraries & tools are emerging:
  • Parallel loading of scripts causes errors
    3 Posts | Last post March 28, 2017
    • Hi,
      In case someone else bumps into this we had came across an issue where the parallel loading of script files caused us some grief. We had a script to get entity logical name from typecode using the RetrieveMetadataChanges request. The issue arose because Sdk.Soap.js was not done loading when the RetrieveMetadataChanges script tried setting its OrganizationRequest prototype. My workaround was to unwrap the existing immediately invoked functions, give them names and wrap the script as a whole in one big iife with a check to see if Sdk.OrganizationRequest and Sdk.OrganizationResponse was set, if not i used setTimeout 0 to defer the definition of the MetadataRequest and its supporting functions/objects.
    • Hi, could you please provide a code snippet showing your solution? It's not so clear to me and I have the same issues trying to run this library on CRM 2016.
    • This is one of the known issues.
  • Sdk.Messages.QueryMultipleSchedulesRequest returns null start
    2 Posts | Last post March 28, 2017
    • Hello,
      I am using the Sdk.Messages.QueryMultipleSchedulesRequest.js library to query the schedules of a subset of resources in my CRM. Creating the request and executing the request gives me a response set of Calendars and TimeInfos for those calendars. Within this response set, I get some information from my "Unavailable" calendar rules, such as the end date and calendarid info. However, the getStart() method always returns a null value. I have checked to ensure that the calendar rules have values in the starttime column, when querying from SSMS. But these same rules return null for the getStart() value. 
      Where is the start being pulled from? Is this value being returned? 
    • Seems like this question isn't specific to the Sdk.Soap.js library. You should get the same data using the .NET SDK assemblies.
      If it is different, that is something we could look into here.
      I would recommend you look to the following SDK resources:
      Or post your question to the CRM developer forum.
  • Sdk.ExecuteMultiple.js returns the same GUID in response over and over
    3 Posts | Last post January 21, 2016
    • I've been using Sdk.ExecuteMultiple.js to make some bulk create requests.  It works great, however when trying to get the IDs out for the created records, I just keep getting the same IDs over and over again.  When looking at the response body, it's correct, it has multiple unique guids, but when the response gets parsed it is like it is only picking up the first id.
      I've posted my code and a question on stack overflow here:
      Any help would be greatly appreciated!
    • I've responded to your Stack Overflow question with a possible fix. Haven't tested on all browsers yet. Please advise if the fix works for you. This is the code I used to test:
      function testExecuteMultiple() {
          var createRequestCollection = new Sdk.Collection(Sdk.OrganizationRequest);
          var executeMultipleRequestSettings = new Sdk.ExecuteMultipleSettings(true, true);
          var account1 = new Sdk.Entity("account");
          account1.addAttribute(new Sdk.String("name", "Account One"));
          var account2 = new Sdk.Entity("account");
          account2.addAttribute(new Sdk.String("name", "Account Two"));
          createRequestCollection.add(new Sdk.CreateRequest(account1));
          createRequestCollection.add(new Sdk.CreateRequest(account2));
          var request = new Sdk.ExecuteMultipleRequest(createRequestCollection, executeMultipleRequestSettings);
              function (response) {
                  response.getResponses().forEach(function (responseItem) {
              function (error) {
    • I am using the modern SOAP endpoint and Sdk.Soap.js,Sdk.ExecuteMultiple.js and Sdk.create.js .It is working fine in IE, but not working in chrome and firefox throws error TypeError: Sdk.CreateRequest is not a constructor.
  • Sdk.RetrieveMetadataChanges.js contains error
    2 Posts | Last post January 11, 2016
    • Hi, 
      It looks like it's not possible to build a complex (to make a filter containing another filter). 
      The validation works incorrectly.  
      It seems the following string:
        function _addValidFilter(value) {
      should be changed to the following one:
        function _addValidFilter(filter) {
    • I think you are right. This would result in an the following error: Sdk.Mdq.MetadataFilterExpression addFilter filter parameter requires a Sdk.Mdq.MetadataFilterExpression.
      You can fix this by editing the library to replace the parameter name if 'value' to 'filter'.
        function _addValidFilter(filter) { 
         if (!(filter instanceof Sdk.Mdq.MetadataFilterExpression)) { 
          throw new Error("Sdk.Mdq.MetadataFilterExpression addFilter filter parameter requires a Sdk.Mdq.MetadataFilterExpression)"); 
      Will try and get this fixed in the source and updated soon. Until then, please see the workaround above.
  • Clear CRM Values
    1 Posts | Last post December 02, 2015
    • Hi,
      It's possible clear values of any type of data?, for example, set to null value type Boolean.
  • XPathEvaluator not defined
    4 Posts | Last post November 20, 2015
    • Hi everybody,
      I've an issue developing some customizations in Mobile CRM app.
      In my JS I calla method of SDK.Soap.js, but in Mobile app environment I get an error: XPathEvaluator is not defined.
      The code breaks here:
       var r = new XPathEvaluator
      What can I use instead of it? Shoul I use DOMParser?
      Did someone have the same problem?
    • Sorry for the delay in responding to this.
      Sdk.Soap.js was written for use in HTML Web resources or form scripts in the CRM Web Applications. It expects to be run in a browser and supports the implementation differences between IE and other browsers which are continuing to become smaller and smaller in latest versions of IE and Edge.
      It hasn’t been tested in mobile applications. Some limited testing using WinJS found it doesn’t work there because WinJS doesn’t appear to allow XPath, which this library depends on extensively. 
      The pattern to parse XML can be found in this function:
      this.selectSingleNode = function (node, xPath) { 
        if (typeof (node.selectSingleNode) != "undefined") { 
         return node.selectSingleNode(xPath); 
        else { 
         var xpe = new XPathEvaluator(); 
         var xPathNode = xpe.evaluate(xPath, node, Sdk.Xml.NSResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null); 
         return (xPathNode != null) ? xPathNode.singleNodeValue : null; 
      If the legacy Microsoft implementation using node.selectSingleNode is not available, it will try to use the browser XPathEvaluator. This would need to be changed to support whatever is the recommended XML parsing object for the mobile platform you are using.
      What platform are you using for your mobile app? 
    • Hi,
      I have the same issue in Mobile App platform WindowsPhone, instead in Mobile App Android or iOS it works fine.
      Anyway in Mobile App WindowsPhone I have also an error if I include jQuery javascript.
      Unfortunately my customer uses WindowsPhone :-(
    • We're having the same issue with the MoCA client (7.1) and a simple retrievemultiple operation.  I will see if I can dig into WinJS and find an alternative for the XML parsing.
  • AliasedValues of type double
    1 Posts | Last post November 03, 2015
    • I think I found a bug when decoding a SOAP response, in the getTypedValue function. For aliased values with a type of double, at line 4764 in Sdk.Soap.vsdoc.js, the code to parse the value is:
        case "double":
          return new Sdk.Double(logicalName, parseInt(Sdk.Xml.getNodeText(aliasedValueNode), 10));
      Which is calling parseInt instead of parseFloat, so any fractional part of the value is lost.
  • Sdk.Soap.js Support
    3 Posts | Last post October 04, 2015
    • Sdk.Soap.js is Support by Microsoft CRM 2015 ???
    • Jersson -
      A simple question but not one I can answer with a simple yes or no. That could be misleading. So I'm going to give you a very specific answer.
      Sdk.Soap.js is a sample which demonstrates how to use the CRM Organization web service '/XRMServices/2011/Organization.svc/web', also known as the Modern app SOAP endpoint.
      Using the Organization web service with JavaScript in web resources is supported. You can find the documented pattern about how to use it here: The organization web service was introduced with CRM 2011 and will be supported for the foreseeable future, including CRM 2015 and beyond.
      Sdk.Soap.js is a sample library which demonstrates how using the Organization web service can be done more easily with a helper library, but it is released as a sample with licensing terms different from those that the CRM Product has. This sample was prepared by the CRM SDK content team and is supported by that team. You shouldn’t call CRM technical support if you have issues with this library. You should use this Q&A. But ultimately, all the Sdk.Soap.js library does is compose and parse XML sent to and returned from the Organization Service. You don’t have to use the Sdk.Soap.js library to do this, but it does make it easier.
       The Sdk.Soap.js library was written using CRM 2013. There are new messages and behaviors which are added to the Organization Service with each version. Sdk.Soap.js only supports those messages and behaviors available when it was written. Basically it doesn’t know about new things added since CRM 2015. It doesn’t include definitions for messages you would find here: and here: Some of these new messages could be made to work. If you look at each of the separate libraries that support each message in the messages folder of the project
    • Continued...
      you will see that they follow a common pattern. There is a request and response class in each and they all inherit from the Sdk.OrganizationRequest class. Other than that, they just include definitions for the members of the request or response and plug them into the request XML sent and parse the values returned in the response. The pattern is relatively simple and one could create a new library to support a message introduced later as long as it uses one of the data types defined in the library.
      There have been other changes in metadata definitions since it was written. Sdk.Soap.js will ignore those and continue to work like it did in CRM 2013. This is because there is an SdkClientVersion SOAP header value which is set to 6.0. To return newer metadata definitions that support newer capabilities in CRM 2015 (such as hierarchical one-to-many entity relationships) the SdkClientVersion would need to be updated and other parts of the Sdk.Soap.js library would potentially need to be updated as well.
      Unless something changes, the SDK Content team has no plans to refresh this library for 2015 or beyond. The main reason is that in CRM 2016 we will have a new Web API using OData v4 which should greatly simplify performing all the operations supported by CRM. Sdk.Soap.js will continue to work, but we expect that more and more people will adopt the Web API as they upgrade to CRM 2016. We are busy preparing content for that release.
      Using the Organization Service is supported for the foreseeable future. Sdk.Soap.js is supported by the SDK Content team and it should continue to work for CRM 2015 and the foreseeable future, but it only provides functionality that was available when it was written, which was for CRM 2013.
  • Unable to get “listmember” entity records by QueryExpression
    3 Posts | Last post July 18, 2015
    • I tried to get “listmember” entity records by QueryExpression by the following code:
          var listmemberQuery = new Sdk.Query.QueryExpression("listmember");
          var values = new Sdk.Query.Guids(["24b58266-a597-e411-80c5-00155d5cdc71"]); // one account record's GUID
           values //values
      The error "Sdk.EntityReference constructor logicalName parameter is required and must be a String." occurred.
      And I also tried it by using FetchExpression, in the result the same error occurred.
      Could you please let me know how to get “listmember” entity records.
      Best regards,
    • Sorry for the delay in responding.
      This was an interesting one. When I reproduced what you were observing I noticed that the error was in parsing the successful response. The listmember.entityid attribute is a lookup, so it should be parsed into an entity reference.
      However, the XML returned did not include a LogicalName value:
                      <b:value i:type="a:EntityReference">
                        <a:KeyAttributes xmlns:c=""/>
                        <a:LogicalName i:nil="true"/>
                        <a:Name i:nil="true"/>
                        <a:RowVersion i:nil="true"/>
      IMHO this is a defect in the design of the feature. All entity references must have an ID AND a type value or they really aren't entity references, it is just a GUID value stored in a Lookup attribute.
      It is interesting to note that the listmember attribute also has an entitytype attribute which returns the type value, in this case 'account', which is the value which *should* be in the entity reference type.
      It was also interesting that I could successfully use either Sdk.Query.Guids or Sdk.Query.EntityReferences to set the array of values for the condition. Both of these work:
      var values = new Sdk.Query.Guids(["759EB14C-C82C-E511-80CF-00155DB16620"]); // one account record's GUID
      var values = new Sdk.Query.EntityReferences([new Sdk.EntityReference("account", "759EB14C-C82C-E511-80CF-00155DB16620")]);
      Bottom line is that if you do not include the listmember.entityid attribute in the columns you return the query works fine.
      I guess I could remove the restriction in this library wish requires all entity references to have a type value, but I don't think that is the right thing to do.
      Rather than querying listmember entity directly
    • Continued..
      Consider the approach described here: and create a query on the account entity which is linked to the listmember entity.
1 - 10 of 20 Items