Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unable to update records using XRMService Toolkit

Posted on by 3,610

I have following code snippet to update a certain record using XRMServiceToolkit but it throws exception as well. I could not find out the reason. any idea what I am missing in it.

function updateOrderStatus(){
var orders = XrmServiceToolkit.Soap.Fetch(query);

var value = Xrm.Page.getAttribute(attr);
var osId = orders[0].attributes['new_testid'];
var update = new XrmServiceToolkit.Soap.BusinessEntity("new_test", osId);

update.attributes["new_assignedto"] = { id: value.getValue()[0].id, logicalName: 'systemuser', type: 'EntityReference' };
update.attributes["new_assignedtodate"] = { value: new Date(), type: "DateTime" };

var result = XrmServiceToolkit.Soap.Update(update);
}


Exception:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter schemas.microsoft.com/.../Services:request. The InnerException message was 'There was an error deserializing the object of type Microsoft.Xrm.Sdk.OrganizationRequest. The value '[object Object]' cannot be parsed as the type 'Guid'.'.  Please see InnerException for more details.


*This post is locked for comments

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Unable to update records using XRMService Toolkit

    Then I have no other suggestions than - good luck learning how to troubleshoot JavaScript - blogs.msdn.microsoft.com/.../debugging-custom-javascript-code-in-crm-using-browser-developer-tools

  • Mohsin Ali Profile Picture
    Mohsin Ali 3,610 on at
    RE: Unable to update records using XRMService Toolkit

    I tried with .id but it pass 'undefined' to osId

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Unable to update records using XRMService Toolkit

    Hello,

    It's definitely better to troubleshoot your code using debugging tools but one line looks suspicious:

    try to replace line

    var osId = orders[0].attributes['new_testid'];

    with line

    var osId = orders[0].attributes['new_testid'].id;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans