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 365 | Integration, Dataverse...
Suggested Answer

How to delete data from entity relationship many-to-many in CRM 365?

(0) ShareShare
ReportReport
Posted on by 5

Hi there,

I have two entities one is <A> another is <B>. the data hierachy will be 

<A> serial number (eg. 6685834) <N:N releationship> mapping to multiple records in <B>. for instance:

6685834

AC-1F

AC-2F

AC-3F

currently, I would like to delete AC-1F, AC-2F, and AC-3F. does anyone have ideas on it or sample code.

thanks

WILL

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Will,

    We couldn't delete intersect entity records directly.

    You should use DisassociateRequest to disassociate many to many relationship.

    https://stackoverflow.com/questions/8802802/how-to-create-and-delete-data-from-entity-relationship-many-to-many-in-crm-2011

    Regards,

    Clofly

  • erhan.keskin Profile Picture
    2,253 on at

    I assume you are asking it because you faced in Unified Interface?

    If so, check this out

    crmtipoftheday.com/.../

  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Will,

    I would like to correct my answer:

    You can use disassociate action in CRM Rest Builder to delete intersect record easily. 

    pastedimage1576158950175v1.png

    The format for delete operation:

    parent_entity(parent_entity_id)/relationshipname(child_entity_id)/$ref

    Below is my test, a book could be sold in many book stores, a bookstore sells many books.

    I remove a book from a book store.

    var req = new XMLHttpRequest();
    req.open("DELETE", Xrm.Page.context.getClientUrl()   "/api/data/v9.1/new_books(41a5cb80-8c07-ea11-a811-000d3a59f6ff)/new_new_bookstore_new_book(c3aaaf8a-e41c-ea11-a811-000d3a59f6ff)/$ref", 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) {
            req.onreadystatechange = null;
            if (this.status === 204 || this.status === 1223) {
                alert("OK!");
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send();

    Thus you can execute the action 3 times for AC-1F, AC-2F and AC-3F.

    Regards,

    Clofly

  • WILL -H Profile Picture
    5 on at

    Hi Clofly,

    thanks for your elaboration on this. I will have it a try. thanks a lot

  • cloflyMao Profile Picture
    25,210 on at

    Hi Will,

    Please let me know whether your problem could be solved with the method. :)

    If you had found my answer helped, please kindly mark as verified, it would be really appreciated.

    Regards,

    Clofly

  • Suggested answer
    WILL -H Profile Picture
    5 on at

    Hi Clofly,

    My colleague had changed another solution to solve it out. and I reckon your solution should be workable.

    Thanks Clofly

  • Community Member Profile Picture
    on at

    I get service.Disassociate("productsubstitute", pr.Id, new Relationship("new_account_productalias"), accts);

    But getting the collection, accts, takes effort.  I want

     service.Disassociate("productsubstitute", pr.Id, new Relationship("new_account_productalias"), true); that just gets them all.

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 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 174

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans