03-12-2008 07:46 AM
03-13-2008 07:39 AM - edited 03-13-2008 07:50 AM
#region Lock DB
//Database MUST be locked before making Schema changes
ActFwk.Database.LockDatabase(Act.Framework.DatabaseLockReason.SchemaChanges);
#endregion
#region Create Field
//Create Field Object
Act.Framework.Database.FieldDescriptor Field;
//Create the Custom Field
Field = new FieldDescriptor("CustomField", Act.Framework.RecordType.Contact, Act.Framework.Database.FieldDataType.Character);
//Set the field's properties
Field.IsPrimary = false;
Field.IsTracked = true;
Field.AllowEmpty = true;
Field.Attributes[FieldProperty.Length] = new LengthAttribute(100);
//Important: You must save your changes
ActFwk.Fields.Save(Field);
#endregion
#region Unlock DB
//Don't forget to unlock your database after changes have been made
ActFwk.Database.UnlockDatabase();
#endregion
If for whatever reason your code errors out and your database is left in the 'locked' state. It can be unlocked via ActDiag.exe
ACT! 2006:
Start > Run > Type: Act8Diag > Ok
ACT! 2007+ :
Start > Run > Type: ActDiag > Ok
Go to the databases tab > Click the grey box to the left of your database > Right click and select 'Unlock Database'.
03-13-2008 09:15 AM
Contact currContact = ActApp.ApplicationState.CurrentContact;
currContact.ContactFields.FieldChanged += new Act.Framework.MutableEntities.MutableEntity.FieldCollection.FieldChangedHandler(ContactFields_FieldChanged);
03-14-2008 06:33 AM - edited 03-14-2008 06:36 AM
Are you tracking changes to individual fields or any change to the contact fields?
03-14-2008 07:49 AM