Creating an association between two entities

This sample creates a new association between two contacts. The sample shows the following tasks:

/// <summary>

/// Creates a new association between two contacts

/// </summary>

private Association CreateAssociation(Contact contactOne, Contact contactTwo)

{

//Log into the framework and retrieve the correct AssociationManager

ActFramework ACTFM = new ActFramework();

ACTFM.LogOn("C:\\Documents and Settings\\Administrator\\My Documents\\ACT\\Act for Win 8\\Databases\\Act8Demo.pad", "Chris Huffman", "");

AssociationManager associationManager = ACTFM.Associations.GetAssociationManager(company, opportunity);

//Create the assocaition

Association association = associationManager.CreateAssociation(contactOne, contactTwo);

//First means of setting association information

association.Fields[StandardField.Details] = "Association Details";

//Second meand of setting association information

AssociationFieldDescriptor field = associationManager.GetFieldDescriptor(StandardField.Entity1Role);

field.SetValue(association, "First entities role in this assocaition");

//Persist the association to the database.

assocaiton.Update();

}