I want to use the Item.Object property to store custom data instead of a descendant class. What is not clear is from which events to read and write the data. I need access to the Item.ID value for sure. In DBDaySource.ItemToFields event when adding an item the Item.ID is 0 for example.
DBxxxSource.OnItemToFields to write data back to the DB from the item
Right. I am not explaining this properly. I use the ID property to store the unique item ID field in the database. In DBDaySource.ItemToFields for a new item the item ID will not have been created yet. but I need it to store the custom data properly. What event can I access the item ID and then populate the .Object so it is available to the edit form?
I do not know when you can or want to set the .ID property, so I can only suggest to set the object after you set the ID if your object depends on your ID.
TDBPlanner is not doing anything itself with PlannerItem.ID.
OK great. So I resolved this problem by using the DBKey to get the autoinc ID from the table. It works but is a bit kludgy. The manual seems to suggest you can use an auto-increment field value for the Key field instead of a GUID by coding the OnCreateKey event. I don't see how this would work but that would be the ideal solution for me. Simply reading the last value and incrementing would not seem safe in a multi-user setting.
Set AutoIncKey = true when you have an auto-inc DB field, i.e. your DB will be responsible for unique key generation and if your DB is multi user capable, it will be reliable.