OrganizationService.Associate Method (String, Guid, Relationship, EntityReferenceCollection)
Applies To: Dynamics CRM 2015
Creates a link between records. (Developer Extensions)
Assembly: Microsoft.Xrm.Client (in Microsoft.Xrm.Client.dll)
public virtual void Associate( string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities )
public: virtual void Associate( String^ entityName, Guid entityId, Relationship^ relationship, EntityReferenceCollection^ relatedEntities )
abstract Associate : entityName:string * entityId:Guid * relationship:Relationship * relatedEntities:EntityReferenceCollection -> unit override Associate : entityName:string * entityId:Guid * relationship:Relationship * relatedEntities:EntityReferenceCollection -> unit
Public Overridable Sub Associate ( entityName As String, entityId As Guid, relationship As Relationship, relatedEntities As EntityReferenceCollection )
Type: String. The logical name of the entity that is specified in the entityId parameter.
Type: Guid.The ID of the record to which the related records are associated.
Type: Relationship. The name of the relationship to be used to create the link.
Type: EntityReferenceCollection. A collection of entity references (references to records) to be associated.
This message works regardless whether the caller is connected to the server or offline.
Privileges and Access Rights
To perform this action, the caller must have privileges on the entity that is specified in the entityName parameter and access rights on the record that is specified in the entityId parameter. For a list of the required privileges, see Delete message privileges.
Notes for Callers
This method creates multiple associations in one transaction between the record that is specified by the entityId parameter and each record in the relatedEntities parameter for the specified relationship in the relationship parameter.
For a one-to-many relationship, this method sets the ReferencingAttribute in the related record to the value of the entityId.
For a many-to-many relationship, this method creates a record in the intersect table for the relationship, which contains the ID of both the referenced and referencing records. The intersect table name is defined in the IntersectEntityName property for the relationship.
For more information about the exceptions that can be thrown when this method is called, see Handle exceptions in your code.
You can use this method to associate any records that participate in a relationship, including records for custom entities.
Access entity relationships (Dynamics CRM 2015)
Developer extensions context object model (Dynamics CRM 2015)
Developer extensions for Microsoft Dynamics CRM 2015
Return to top
© 2017 Microsoft. All rights reserved. Copyright