09-09-2010 09:20 PM
I'm creating a customer field and receive this error message while debugging. This with ACT 2011 Professional. The code has not change from the Previous version of ACT! The code worked find in ACT2010.
field = new FieldDescriptor("FieldName", "AliasName", descriptor, FieldDataType.Decimal); field.AllowEmpty = true; field.Attributes[FieldProperty.DecimalPrecision] = new DecimalPrecisionAttribute(12, 2); actApplication.ActFramework.Fields.Save(field);
See error below:
System.NullReferenceException was unhandled |
Message=Object reference not set to an instance of an object. |
Source=Act.UI.PickList |
StackTrace: |
at Act.UI.PickList.DBFieldEditor.Dispose(Boolean disposing) |
at Act.UI.PickList.BasePickListControl.Dispose(Boolean disposing) |
at System.ComponentModel.Component.Finalize() |
InnerException: |
Anthony Polk
CRM Computers
09-10-2010 07:55 AM - edited 09-10-2010 07:57 AM
It may be an issue with the entitiy you trying to add the field to. I was able to add a decimal field to contacts. The signature I used for the new FieldDesctiptor was different, but other than that the code is the same and doesn't throw the exception
try { FieldDescriptor newField = new FieldDescriptor("TestField",Act.Framework.RecordType.Contact, FieldDataType.Decimal);
newField.AllowEmpty = true; newField.Attributes[FieldProperty.DecimalPrecision] = new Act.Framework.Database.DecimalPrecisionAttribute(12, 2); ActApp.ActFramework.Database.LockDatabase(Act.Framework.DatabaseLockReason.SchemaChanges); ActApp.ActFramework.Fields.Save(newField); } catch (Exception x) { } finally { ActApp.ActFramework.Database.UnlockDatabase(); }
09-10-2010 08:51 PM
The exception is thrown after 23 fields are created in the entity. Why? The code works up to that point, then breaks.
Anthony Polk
CRM Computers