web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Deassociate entities on update with the Web API

(1) ShareShare
ReportReport
Posted on by

Hello everyone

Accordingly to documentation, with Web API, we can Associate entities on update (https://msdn.microsoft.com/en-us/library/mt607875.aspx#Anchor_5)

Is it possible to do the same thing for deassosiating, with a some kind of @odata.unbind? For instance, I have three lookups and I want to clear them all at once, without sending of a DELETE request three times, like in Remove a reference to an entity example (https://msdn.microsoft.com/en-us/library/mt607875.aspx#Anchor_2)

Thanks for advance

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    To disassociate records we can write following request using DELETE method:

    function disassociateRequest(accountID, buildingID) {
     
        var serverURL = Xrm.Page.context.getClientUrl();
        var req = new XMLHttpRequest();
        req.open("DELETE",serverURL+"/api/data/v8.0/accounts("+accountID+")/him_building_account/$ref?$id="+serverURL+"/api/data/v8.0/him_buildings("+buildingID+")", true);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.onreadystatechange = function() {
            if (this.readyState == 4 /* complete */ ) {
                req.onreadystatechange = null;
                if (this.status == 204) {
                    alert('Record Disassociated');
                } else {
                    var error = JSON.parse(this.response).error;
                    alert(error.message);
                }
            }
        };
        req.send();
    }

    Hope this helps you.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Alexander,

    Please check this tool, it helps you to create those queries to use on CRM.

    crmrestbuilder.codeplex.com

    Hope it helps!

    Regards,

    Please verify if it solves your problem.

  • Community Member Profile Picture
    on at

    Thank you for your response.

    Yes you are right, but this will work only for one lookup, and I want to affect more lookups in one request. Update can fill data in few lookups at once, but I don't know how to perform reverse operation and delete data from few lookups in one update request.

  • Community Member Profile Picture
    on at

    Hi Ezgi.

    Thank you for response.

    I am familiar with this great tool and tested some variations before asking a question here. I am tried to pass nulls or zero guids without any luck.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans