Terry Bottorff (08/20/2010)
Thank you for the extreme amount of help you have given me. I will try and get back to this later and see what is happening.
I do have a question though. If you have a simple table that is say (tableA) and thus a BO with the following structure:
PK as primary key, Name, amount,
and you fill TableA with with say: me.TableABO.filldatatable("Select name, amount from TableB")
Can you put something in the Select so that the PK column will exist and not cause problems when you try and save tableA's BO?
If you don't have something there it won't let you save because the BO does not have a Primary Key and if I put save 1 in for all the records and the PK is autoincrementing I get an error?
Hi Terry,
If you plan to update the table via the BO you MUST have the PK column as part of your select statement so it will know which record to update.
me.TableABO.filldatatable("Select PK, name, amount from TableB")
StrataFrame Business Objects are very, very, very flexible and that make them powerful. One sample I used a lot is having a JOIN statement to select a field description, then in the BO I have a Custom Field Property that will return the column name for the description field, of course your SQL statement should have that column as part of it. Here is a sample of one of my Custom Field Properties:
Protected Overrides Function GetCustomBindablePropertyDescriptors() As FieldPropertyDescriptor()
' Create and return a new array of FieldPropertyDescriptor objects that contains
' the ReflectionPropertyDescriptor for the Custom Fields.
Return New FieldPropertyDescriptor() _
{New ReflectionPropertyDescriptor("cfp_CustomerName", GetType(bizTransactionItems))}
End Function
BusinessFieldDisplayInEditor(), _
Description("Customer Name"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Overridable Property [cfp_CustomerName]() As String
' Check to see if datatable contains the custom field in
' case object was filled by a method that doesn't contain the field.
Get
Dim columnName As String = "cfp_CustomerName"
If Me.CurrentDataTable.Columns.Contains(columnName) Then
If Not TypeOf (Me.CurrentRow.Item(columnName)) Is DBNull Then
Return CStr(Me.CurrentRow.Item(columnName))
Else
Return String.Empty
End If
Else
Return String.Empty
End If
End Get
Set(ByVal value As String)
Dim columnName As String = "cfp_CustomerName"
If Me.CurrentDataTable.Columns.Contains(columnName) Then
Me.CurrentRow.Item(columnName) = value
End If
End Set
End Property
Like I said, the field column "cfp_CustomerName" should exist in the SQL statement used to fill the BO, if not, the used of the Custom Field Property BO.cfp_CustomerName will just return a blank space. There are a lot of samples in the forums on how to use the Custom Field Properties as well as in the SF help file. I must admit that the above code is a combination of multiple SF developers suggestion in the forums, so it is not my idea
P.S.
Copy and paste the code in VS so it will make more sense.