Why are these fields deemed to be empty?


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

Please see attached screen shot. This is a DevExpress grid populated from a stored proc. All the fields from the left, up until the column with 999, are "required fields" in the BO. The ones to the right of the 999 are not. The bottom panel shows the data that is returned by the stored proc.

I changed the value in the 4th column from 100 to 3100 and clicked Save. This fired a Broken Rule on the 5 marked columns saying they are 'required'. From the database listing you can see the checkboxes with errors have a value of False (0) and the column second from the right (which is an integer column) also has a value of 0.

If I change the integer column from 0 to 1 the broken rule goes away for that column. If I then change the column back to its original value of 0 the broken rule still doesn't fire. However, the same process does not work for the checkboxes, i.e. ticking a checkbox to True stops the broken rule from firing but once it is ticked back to False the rule fires again.

Cheers, Peter

Attachments
SF12.JPG (86 views, 274.00 KB)
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, the required fields validation tests on the "default" value for each data type... the value that the columns are initialized to if the AllowNullValuesOnNewRow = False.  So, if you want to test on NULL values, then you'll need test on those values yourself rather than use the built-in required fields options.
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Ben,

Sorry, you have lost me... The row in question isn't a new row, it is the first row in the database (refer to the table in the screen shot I sent) and every column has a value - it just seems to be False columns and zero columns that are creating the problem.

A more general question relating to your answer. The BO in question does have "AllowNullValuesOnNewRow = False" which is what I want, i.e. I want to be in control of setting defaults which I do as follows:

Private Sub boATT_SetDefaultValues1() Handles Me.SetDefaultValues

Me.ATTActive = True

Me.ATTDType = "1"

Me.ATTFBatch = False

Me.ATTFHide = False

Me.ATTID = Guid.NewGuid()

Me.ATTLookUp = False

Me.ATTMandInLU = False

Me.ATTRangeFrom = 0

Me.ATTRangeTo = 999

Me.ATTRBatch = False

Me.ATTSBatch = False

Me.ATTSequ = 0

Me.ATTSHide = True

Me.ATTSPBatch = False

Me.ATTType = "1"

End Sub

When I create a new row the above code fires and the correct default values are set - I can see them in the UI. However, when I click Save I have the same problem I get with an existing row, i.e. any fields set to False or Zero fires the Required Fields broken rule.

Cheers, Peter


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Whether the row is new or not, required fields assume that False and 0 are empty.  You can build the source code in debug mode to see how required fields are validated.  But the reason they are giving you the error is because they are set to false for the booleans and 0 for the integers.  Generally boolean values are not good candidates for the required fields collection since there are only two values.  If you are using NULL support, this value gets translated into a False in most cases.

I recommend removing these fields from the Required Fields collection and just adding your own business logic in the CheckRulesOnCurrentRow event.

Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Trent,

Ok, I understand however I'm left somewhat bemused as to why False and 0 are not considered 'real values'.

Cheers, Peter

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Ok, I understand however I'm left somewhat bemused as to why False and 0 are not considered 'real values'.

They are considered "real values", they are just considered to be empty. 

Steve L. Taylor
Steve L. Taylor
StrataFrame Developer (70 reputation)
Group: StrataFrame Developers
Posts: 40, Visits: 91
When we test on values within the business object, we generally use the .Item property, which evaluates the strong-typed properties of the subclass and returns the values.  So, .Item("ATTLookUp") will call the Get of the ATTLookUp property.  So, when testing default values, since most columns are .NET value types (not reference types), we have to test on the "default" value for a value type (because value types always have a value).  We do test on DBNull.Value from the CurrentRow("ATTLookUp") to test required fields as well, but we also have to test on the default for value types, so 0 and False are considered to have not been set.  Generally, you won't want to use the RequiredFields for a Boolean property, you'll want to test the CurrentRow("FieldName") Is DBNull.Value on your own.
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Steve,

Thanks for explanation. I have no problems with the Boolean side of things - we simply don't make them Required and make sure we initialise them when creating a new row - from then on the user can only toggle between 0 and 1. However, I just want to be sure I understand the restriction re 'value type' columns. As I understand it, for any 'value type' column, we cannot use the RequiredField option in StrataFrame if zero is a valid value - can you please confirm.

Cheers, Peter

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, if you want 0 to be a valid value, then you will need to test on the CurrentRow("FieldName") Is DBNull.Value within the CheckRulesOnCurrentRow event.
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