11-09-2015 01:47 PM
I've created a new contact field as below. If I wanted to delete the field later how would I go about it?
Instance.ActFramework.Database.LockDatabase(Act.Framework.DatabaseLockReason.SchemaChanges) Field = New Act.Framework.Database.FieldDescriptor(FieldName, Act.Framework.RecordType.Contact, Act.Framework.Database.FieldDataType.Character) Field.Attributes(FieldProperty.Length) = New Act.Framework.Database.LengthAttribute(100) Instance.ActFramework.Fields.Save(Field) Instance.ActFramework.Database.UnlockDatabase() Instance.ActFramework.Fields.RefreshSchema()
11-11-2015 08:09 AM
I found the solution. There doesn't appear to be any way of getting the specific field without looping through the collection.
Dim Fields As FieldDescriptorCollection Dim FieldName As String = "MyField" Fields = ACT.Fields.GetFields(Global.Act.Framework.RecordType.Contact) For i As Int32 = 0 To (Fields.Count - 1) Step 1 If (Fields(i).Alias = FieldName) Then ACT.Database.LockDatabase(DatabaseLockReason.SchemaChanges) ACT.Fields.Delete(Fields(i)) ACT.Database.UnlockDatabase() ACT.Fields.RefreshSchema() End If Next