XrmServiceToolkit 1.3.1 doesn't work as the previous one

Dec 7, 2012 at 9:23 AM


I have upgraded to this version on my CRM Online environment but it seemed like the XrmServiceToolkit.Soap.Create and the XrmServiceToolkit.Soap.Retrieve functions are not working properly. Do you have any idea.


Dec 7, 2012 at 11:03 AM


I just tested 1.3.1 with an online trial without problems.

    try {
        var createContact = new XrmServiceToolkit.Soap.BusinessEntity("contact");
        createContact.attributes["firstname"] = "Diane";
        createContact.attributes["lastname"] = "Morgan";
        createContact.attributes["middlename"] = "<&>";   // Deliberate special characters to ensure that the toolkit can handle special characters correctly.
        createContact.attributes["gendercode"] = { value: 2, type: "OptionSetValue" };
        createContact.attributes["familystatuscode"] = { value: 1, type: "OptionSetValue" }; // Picklist : Single - 1
        createContact.attributes["creditlimit"] = { value: 2, type: "Money" };
        createContact.attributes["birthdate"] = new Date();
        createContact.attributes["donotemail"] = true;
        createContact.attributes["donotphone"] = false;
        createContact.attributes["parentcustomerid"] = { id: Xrm.Page.data.entity.getId(), logicalName: "account", type: "EntityReference" };

        var contactId = XrmServiceToolkit.Soap.Create(createContact);

        var cols = ["firstname", "lastname", "middlename", "familystatuscode", "ownerid", "creditlimit", "birthdate", "donotemail", "donotphone"];
        var retrievedContact = XrmServiceToolkit.Soap.Retrieve("contact", contactId, cols);
        if (retrievedContact != null) {
    catch (err) {

Give it a try and let me know if you still have issues.


Dec 7, 2012 at 8:23 PM

Thanks Jaimie for your quick reply,

Here is my code 

function getFullNameUser() {
    try {
    var currentUserId = XrmServiceToolkit.Soap.GetCurrentUserId();

        var cols = ["firstname", "lastname"];
        var user = XrmServiceToolkit.Soap.Retrieve("systemuser", currentUserId, cols);
    catch (err) {

I get the error : Unable to get "value" property of a reference null or undefined

It works perfectly with the previous one.

I tried to moved because with the previous one I have issues when trying to create entities with decimal attributes.

Dec 8, 2012 at 8:46 PM


The code is fine and I have tested at my end which running the current user as system administrator.

The problem might be caused by the user who executed the code does not have read privilege in their security role settings.

Have a check and let me know if that explains the situation.


Dec 9, 2012 at 10:50 PM
Edited Dec 10, 2012 at 9:53 AM


This user has all privileges on the security role settings. The same code works perfectly when I change the XrmServiceToolkit.js file with the previous one (version 1.3).

Actually my computer works on Windows 8 with IE10, when I test it on IE8 Compatibility, it works fine.

I get the following error :

"cannot convert the xml string to a cross-browser XML object"

And then :

There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:id. The innerException message was 'there was an error deserializing the object of type System.Guid. The value '' can not be parsed as the type 'Guid'.'

Do you have any explanation of this ? 


Dec 10, 2012 at 9:58 AM

Actually my computer works on Windows 8 with IE10, when I test it on IE8 it works fine.

Hi there.

Here is my test environment for the code

1. Client: Windows 8 64-bit. IE10

2. Server: CRM online (5.0.9690.2747)

3. Framework: XrmServiceToolkit 1.3.1

I would recommend you try to debug the code using IE developer tool (F12) and see if there are any errors.

Let me know,



Dec 10, 2012 at 11:21 AM

Thanks Jaimie,

When debbuging, I found that the problem was when trying to get the connected user ID in this function GetCurrentUserId().


        /// Sends synchronous request to retrieve the GUID of the current user.
        var request = "<request i:type='b:WhoAmIRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts' xmlns:b='http://schemas.microsoft.com/crm/2011/Contracts'>" +
                        "" +
                        "" +
                        "WhoAmI" +
        var xmlDoc = doRequest(request, "Execute");

        return $(xmlDoc).find('a\\:Results').children().eq(0).children().eq(1).text();


It threw the exception : "cannot convert the xml string to a cross-browser XML object".

I get the same error on the retrieve query :

return doRequest(msgBody, "Retrieve", !!callback, function (resultXml) {
            var retrieveResult = $(resultXml).find("RetrieveResult").eq(0)[0];
            var entity = new businessEntity();

            if (!async)
                return entity;
            // ReSharper disable NotAllPathsReturnValue


But I also find out this problem occurs only in my HTML web resource in which I link my javascripts files :

<script type="text/javascript" src="../javascripts/jquery.js"></script>
    <script type="text/javascript" src="../javascripts/json2.js"></script>
    <script type="text/javascript" src="../javascripts/jqueryui.js"></script>
    <script type="text/javascript" src="../../../ClientGlobalContext.js.aspx"></script>
    <script type="text/javascript" src="../javascripts/XrmServiceToolkit.js"></script>

These functions work perfectly when called directly from CRM form events.

Any idea ?


Dec 12, 2012 at 12:46 AM
Edited Dec 12, 2012 at 12:47 AM

Hi There.

I have tested several scenarios using version 1.3.1 for both on-premise and online.

So far for the scenarios I have run, there is only one which gave me the exact problem when trying to retrieve records

-CRM Server: CRM online

-Scenario: Call a web resource from a ribbon button on form


Somehow, when calling a web resource from a ribbon button for online CRM, when trying to create a XML document, even using IE, the XML document is created using the following code as if the explorer is non-IE

 if (window.DOMParser) {
     // ReSharper disable InconsistentNaming
     var parser = new DOMParser();
     // ReSharper restore InconsistentNaming
     xmlDoc = parser.parseFromString(txt, "text/xml");

Therefore, the current logic in 1.3.1 could not deserialize the entity properly. I will work on the issue and perform more testing and update a new version shortly. In the meantime, I would recommend you stay with 1.3 until the problem is resolved for your case.


Dec 12, 2012 at 1:48 AM

Hi Jaimie,

Thanks for your explanations.

I am using the 1.3 version, but do you have any workaround for the Decimal problem when using XrmServiceToolkit.Soap.Create ?


Dec 12, 2012 at 9:45 AM

Try this

//overcome limitations of numbers with type specified.... 
createContact.attributes["numberofchildren"] = { value: 2, type: "int"}; 

createContact.attributes["exchangerate"] = {value: 1.5617, type: "decimal"}; 

createContact.attributes["address1_latitude"] = { value: 1.5617, type: "double" }; 

createContact.attributes["creditlimit"] = { value: 2, type: "Money" }; 
Dec 12, 2012 at 2:46 PM

Thanks Jaimie, it works fine.