Randy,
I can't answer your theoretical questions, but I might offer some insight into how to do what you propose in your code. The thing to recognize is that based on the code below, you know the type of the parent business object and the field you want to check, so strong typing becomes your friend
Here is my suggestion at some .NET code. A couple of notes. First, I just typed this in, so there may be some spelling errors/syntax errors. I just wanted to give you an idea of how to do what you are trying to do. Second, Me is the object reference to the instance of a type in VB ('this' is used in C#). I've written this as if it was happening on a form, with a child bo named myChildBO. I've called the parent BO InsturmentBO. Any or all of that could be wrong...again I hope this gives you some idea of how it might be done in .NET.
'-- Validate that a parent BO is set
If Me.myChildBO.ParentBusinessObject IsNot Nothing then
'-- Cast parent BO to its actual type
Dim myParentBO As InsturmentBO = DirectCast(Me.myChildBO.ParentBusinessObject,InsturmentBO)
With myParentBO
'-- InsturmentName is now a strongly typed property, you make changes to your InsturmentBO
' and this will not compile...no hidden bugs
If .InsturmentName = "Atlas" Then
'-- Call validation code
End If
End With
End If
Finally, this works if you know what the parent BO type is and what the field name is. If you don't, then you could use this code instead:
'-- Validate that a parent BO is set
If Me.myChildBO.ParentBusinessObject IsNot Nothing then
'-- Can't cast the BO, but all BOs are wrapping an ADO.NET DataTable, which we can use
Dim myParentDataTable As System.Data.DataTable = Me.myChildBO.ParentBusinessObject.CurrentDataTable
'-- You can access any column via the rows.item property of a datatable.
' fieldName is a variable that is filled with the name of the column to check and
' validData is a variable to check it against. This likely would only work if you
' knew the data type of the validData, in this case I'm using a string.
If CType(myParentDataTable.Rows.Item(fieldName),String) = validData Then
'-- Call validation code
End If
End If
I hope this helps. I was pulling my hair out (what little there was to start with) when I started .net and SF about 7 months ago. Hang in there, there is light at the end of the tunnel (and it's probably not a train
).