Retrieving a list of associated entities (EntityList) and update association details

This sample demonstrates the use of an AssociationFieldDescriptor to interact with other entities in the Act! framework. Currently supported entities are Opportunities, Companies, Groups and Contacts.

/// <summary>

/// Retrieves an entity list of contacts associated with a given contact

/// and updates the associaton information.

/// </summary>

private void UpdateAssociatons(Contact contact, string newRole)

{

//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("Group", "Opportunity");

//Retrieve the entity list.

Act.Framework.Entities.EntityList entityList=associationManager.GetAssociatedEntities(null, contact);

//Retrieve the field descriptor

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

//Enumerate each entity and update the role details.

foreach (Act.Framework.Entities.Entity entity in entityList)

{

roleField.SetValue(entity, newRole);

((IUpdateableEntity)entity).Update();

}

}