One Custom Field Shows and The Other Does Not


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I have a Form where I am trying to use 2 Custom Fields. One works as it should the other does not?

I have attached a picture showing that the Custom Field shows up in the BO Visualizer and a picture showing that it does Not show up in a MessageBox nor a Bound Text box???????

Here is my Custom Field Code:

Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor("Cowboy_Name", GetType(MyBaseRoughStockBO)), _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor("Cowboy_InvertedName", GetType(MyBaseRoughStockBO)), _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor("PRCANUM", GetType(MyBaseRoughStockBO))}

End Function

<

Browsable(False), _



BusinessFieldDisplayInEditorAttribute(), _
Description("PRCA Number"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property PRCANUM() As String

Get

' Return MyBase.RequiredFields

If Me.CurrentDataTable.Columns.Contains("Membershipcd") Then

If Not TypeOf (Me.CurrentRow.Item("membershipcd")) Is DBNull Then

Return CStr(Me.CurrentRow.Item("membershipcd")) + Me.CurrentRow.Item("membershipnumber").ToString

Else

Return ""

End If

Else

Return ""

End If

End Get

End Property

 

I'm Sorry I can not get the last part to format correctly? This is the Custom Field that Shows in the BO but not in the MessageBox nor the Bound Text Box?

TIA.

 

 

   
Attachments
ShowsinBOVisualizer.PNG (138 views, 4.00 KB)
MessageboxResult.PNG (151 views, 13.00 KB)
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Couple of things...
  1. Why are you checking if "Membershipcd" exist? could it be possible that this field would not exist in this BO? or is this part of another table and you are using a JOIN SELECT to get this field?, if this is the case, then the field will only have a value when getting the data, so at the time you are using this property, it may not have any value.
  2. When using custom field properties (CFP) that will use values of the BO fields, I prefer to use the Me.FieldName instead of the Me.CurrentRow.Item("ItemName").  Also if you set your BO properties in the BOM to deal with Null values, then you don't need to check for DBNull, only check the property value directly.


Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I am using a Join Select to get it out of another table. It is working with the other name field and the Name field and prcanum field are both coming out of the same joined table?????? 

I am checking to see if it exist since that was part of a sample I saw and used one time. It will be there and I believe I already am dealing with it in the BO. Yes I do handel it in the BO so I really don't need that piece. Just left over from a copy and paste when I started using CFP.

Any other Thoughts?

Have a Great and Prosperous New Years.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Ok, if using a JOIN to get the field, then your code is OK.  Basically what is happening is that when you are accessing the BO.PRCANUM, if those fields included in the JOIN are empty, then you will not get anything, this could happen when adding a new record and trying to show the BO.PRCANUM will be empty.

If you debug the code before showing the message box image, you will see the field is empty.  Put a breakpoint in your property Get line and see what happen when showing the value in the message box.

On a side note, I try to distinguish my Custom Field Properties form regular BO properties by prefix them with "cfp_", also in my JOIN SELECT I name those fields with the prefix ex: SELECT membershipcd AS cfp_membershipcd or do the expression at the field level instead of the BO like SELECT (membershipcd + membershipnumber) AS cfp_PRCANUM, then in the BO CFP I use the required column as expected.  I use a lot of CFPs and in some cases like when adding a new record, I need to show the value, so in the CFP GET I check for empty value and even do a search to show the correct value, here is a sample:


    <Browsable(False), _
     BusinessFieldDisplayInEditor(), _
     Description("Card Name with the Card Code."), _
     DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
     Public Overridable ReadOnly Property [cfp_CardName]() 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_CardName"
             If Me.CurrentDataTable.Columns.Contains(columnName) Then
                 If Not TypeOf (Me.CurrentRow.Item(columnName)) Is DBNull Then
                     '-- In some cases the Me.CurrentRow.Item(columnName) could be empty so
                     '   lets look at the value if there is a FK_Items value
                     Dim cfpCardName As String = CStr(Me.CurrentRow.Item(columnName))
                     If String.IsNullOrEmpty(cfpCardName) And Me.Count > 0 Then
                         Using bo As New bizItems
                             bo.FillByPrimaryKey(Me.FK_Items)
                             If bo.Count > 0 Then
                                 cfpCardName = bo.ItemName
                             End If
                         End Using
                     End If
                     Return cfpCardName
                 Else
                     Return String.Empty
                 End If
             Else
                 Return String.Empty
             End If
         End Get
     End Property


Hope that will give you an idea to help you find the issue.

P.S.
Happy new year to you too!!!!


Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Edhy I have not put any of your code into use yet but I will but I thought I would show you some other pictures so you can see what I think is working yet not working?

The first picture is the BO visualizer that shows the CF and at least Visually they are Full. Then I show you the Synch List with text boxes and in the Synch List one of the CF show up and one of the CF shows in a bound text box but not the PRCANum in the other bound textbox. Also, then the messagebox shows blank for the me.bbpointsbo1.prcanum ......

Then I added the CF to the synch list and they all show as blanks but again Visually in the BO Visualizer they are all there?
Attachments
Visualizer4Records.PNG (142 views, 4.00 KB)
CustomFieldsWorkingandNot.PNG (132 views, 6.00 KB)
CustomFieldsWorkingandNot2.PNG (139 views, 25.00 KB)
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Op's I forgot the synch list with the CF added to it.

Could it be because it is a Calculated CF?
Attachments
SynchList.PNG (133 views, 4.00 KB)
Edited 13 Years Ago by Terry Bottorff
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

So the problem is that it is not showing in a listview?

I believe my previous explanation has a lot to do because it is a calculated field as such the CFP will only contain data when the source SELECT returns the data for it.  With listview it could be tricky in a sense of how you are loading its data ex ParentFormLoading VS manually loading.  I love SF ListViews, but I learned in a hard way that it is a good idea to have control on when to load the data (lv.Refresh()), so in the listview Populate data settings I always use a copy data from bo and manually drop a BO instance in the form, assign it to the list view and fill this BO manually then refresh the listview.

Now if after reviewing my suggestions still you don't get it to work, please create a small VB sample project using one of the SF Sample database tables that would duplicate the issue and upload it here, I will gladly take a look and make it work or if you prefer, I can do one remote support session to take a look at the issue on hand with your project, feel free to email for connection details.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Edhy I put a Break on the Get and I must have changed something else because it is working. I have NO IDEA why. I did delete some of my code and put some of your code into play and so I am sure I had some weird character in my code that your code fixed.

Thanks so much.

I don't believe how much time I spent chasing a mystery....!
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Glad it is working out.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Well after all of this. I was getting an error every not and again so it was time to delete the whole form and start again. Even started with a little older version of the project. Everything seems to work now so I am really not sure about any of the problems I was having.

Just a bug in the night I think.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search