viernes, 13 de septiembre de 2013

CRM 4.0 - Unir entidades en relaciones de Muchos a Muchos (M:M)

     CrmService crmService = GetCrmService("ie");

            crmService.Credentials = new System.Net.NetworkCredential("xx", "xx", "xx.com");
            contact contacto = new contact();
            contacto = (contact)crmService.Retrieve(EntityName.contact.ToString(), new Guid("5EAE6318-58B9-DC11-AFD6-000C299B7642"), new AllColumns());

            new_idiomas ingles = new new_idiomas();
            ingles = (new_idiomas)crmService.Retrieve(EntityName.new_idiomas.ToString(), new Guid("C0EDC631-A2BF-DC11-A14A-000C299B7642"), new AllColumns());

            AssociateEntitiesRequest request = new AssociateEntitiesRequest();

            request.Moniker1 = new Moniker();
            request.Moniker1.Id = new Guid(contacto.contactid.Value.ToString());
            request.Moniker1.Name = EntityName.contact.ToString();
            request.Moniker2 = new Moniker();
            request.Moniker2.Id = new Guid(ingles.new_idiomasid.Value.ToString());
            request.Moniker2.Name = EntityName.new_idiomas.ToString();
            request.RelationshipName = "new_new_idiomas_contact";

            crmService.Execute(request);

No hay comentarios:

Publicar un comentario