locked
CRM 2011: Disassociate records in an N to N relation RRS feed

  • Question

  • I have two custom entities A and B and a many to many (N to N) relation between them. Using the UI, I can associate a record of B with a record of A by clicking B in the navigation bar to the left and clicking Add Existing B in the ribbon. But how do I remove the association without deleting the related record? Is the only possibility really to create a custom button and send a DisassociateRequest from script?

    Friday, August 19, 2011 11:35 AM

Answers

  • Hi,

    Open the related view on XX that displays the link to X1 and X2. Select the X2 record. Then, mouse over the "delete" X which in this case changes to a "remove" x. Note the alt text: "When you remove a record, it still exists in the system". This "X" just deletes the relationship

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, August 19, 2011 12:51 PM

All replies

  • Hi,

    CRM keeps N:N relation into a sperate table so deleting the N:N record will not delete the entities (A or B records but will only delete the record which has both A and B primary keys. So there is no need to DisassociateRequest for N:N , it is only required for 1:N relationship removal.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, August 19, 2011 12:45 PM
  • Yes, but don't want to delete records directly in the database. I want to be able to do it in the web user interface.

    Friday, August 19, 2011 12:49 PM
  • Hi,

    Open the related view on XX that displays the link to X1 and X2. Select the X2 record. Then, mouse over the "delete" X which in this case changes to a "remove" x. Note the alt text: "When you remove a record, it still exists in the system". This "X" just deletes the relationship

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, August 19, 2011 12:51 PM
  • Try it, deleting the relationship does not delete the record itself.
    Friday, August 19, 2011 1:00 PM
  • I am glad that you find your answer, please if you can vote as Helpful and Mark as answer.
    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, August 19, 2011 1:01 PM
  • You're right of course. I could have sworn I tried that with a different result.
    Friday, August 19, 2011 1:50 PM
  • How can we achieve this same(remove) functionality by code? Can we achieve this through plugin? If so .. do you have sample code for this?

     

    Thanks in advance!

    Wednesday, September 7, 2011 11:56 AM
  • Hi,

    The example used in the following post is to disassosiate 1:N relationship, you can use the same example to disassosiate N:N relationship by passing the N:N relationship name.

    For a many-to-many relationship, this method deletes a record in the intersect table for the relationship. The intersect table name is defined in the IntersectEntityName property for the relationship.

    http://mileyja.blogspot.com/2011/05/how-to-use-disassociate-requests-to.html


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by DynamicTwenty11 Wednesday, September 7, 2011 12:38 PM
    Wednesday, September 7, 2011 12:19 PM
  • Thank you for quick response. This helps.
    Wednesday, September 7, 2011 12:38 PM