Step by Step: Validate and Invalidate Fields
Step 1 - Add the following DefineFieldRules event handler code to the batch handler class.
Private Sub FoodBankTransactionAddBatchHandler_DefineFieldRules(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.DefineFieldRules
With Me.FieldRules.ValidInContextRules
'We can add a field rule to the FieldRules.ValidInContextRules collection that
'will be used to determine if the field is valid in the given context by associating
'the Receipt Printed field within the batch with a deferred condition object.
'When a field becomes not valid in context, then the field’s value is cleared,
'the field is disabled, and the field is marked as not required.
'When a field becomes valid in context then the field will be enabled
'and be populated with the default value.
'When the Transaction Type is set to Distribute, the Receipt Printed field
'will be cleared and disabled.
.Add(RECEIPTPRINTED, FieldValue(FOODBANKTXTYPECODE) = TXTypeCodes.Receive)
End With
End Sub