locked
Microsoft CRM 4.0 Import onto Many to Many relationship RRS feed

  • Question

  • Hi

    I currently have 2 entities in CRM 4.0 linked using the system many to many link. What I would like to do is import some data to populate this relationship. there does not seem to be a way to import data onto the relationship, only entities. I could use a link entity but I am attempting to stay away from this.

     

    Is there a tool/method for getting data into a N:N Relationship>?

    Tuesday, October 7, 2008 1:54 PM

Answers

  • There is no easy way of doing this. Although you can create a small code snippet to do this for you. Use AssociateEntitiesRequest class and following code to associated two entities related as N:N relationship. Similarly use DisAssociateEntitiesRequest class for removing their association. 

     


    AssociateEntitiesRequest request = new AssociateEntitiesRequest();

     

    request.Moniker1 = new Moniker();
    request.Moniker1.Id = new Guid("B050F053-6968-DC11-BB3A-0003FFBAD37A");
    request.Moniker1.Name = EntityName.lead.ToString();

     

    request.Moniker2 = new Moniker();
    request.Moniker2.Id = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");
    request.Moniker2.Name = EntityName.contact.ToString();

     

    request.RelationshipName = "contactleads_association";

     

    service.Execute(request);

     

    Cheers,

     

    Wednesday, October 8, 2008 4:56 AM
    Moderator
  • Hi,

     

    I have created a small importer application using same code snippet for this reason. Although its a bit hardcoded but with a few changes it can work for you.

    Wednesday, October 8, 2008 8:09 PM
    Moderator

All replies

  • There is no easy way of doing this. Although you can create a small code snippet to do this for you. Use AssociateEntitiesRequest class and following code to associated two entities related as N:N relationship. Similarly use DisAssociateEntitiesRequest class for removing their association. 

     


    AssociateEntitiesRequest request = new AssociateEntitiesRequest();

     

    request.Moniker1 = new Moniker();
    request.Moniker1.Id = new Guid("B050F053-6968-DC11-BB3A-0003FFBAD37A");
    request.Moniker1.Name = EntityName.lead.ToString();

     

    request.Moniker2 = new Moniker();
    request.Moniker2.Id = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");
    request.Moniker2.Name = EntityName.contact.ToString();

     

    request.RelationshipName = "contactleads_association";

     

    service.Execute(request);

     

    Cheers,

     

    Wednesday, October 8, 2008 4:56 AM
    Moderator
  •  

    Hi and thanks for the replies.

    I have decided to use a custom entity to do the linking. The link posted is only useful for CRM3.0, Im using 4.0

     

    Wednesday, October 8, 2008 10:26 AM
  • Hi,

     

    I have created a small importer application using same code snippet for this reason. Although its a bit hardcoded but with a few changes it can work for you.

    Wednesday, October 8, 2008 8:09 PM
    Moderator