If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

About the Vehicles Entity DisposalMethod and DisposalDate Fields Sample Validation Script

These fields contain a validation script which ensures that when one field is set, the other field must also be set. (In other words, if a user enters a Date Disposed for a vehicle, then the user must also select a Disposal Method.)

Within the context of the sample application, this requirement is defined in BPR12: Track Vehicle Disposal and the implementation is described in About the Data Quality Design for the Sample Application.

The full text of the script for the DateDisposed field appears below. The field validation fails if the Disposal Method is set to a value other than N/A and the DateDisposed is either blank or NULL. Also, the script prevents a user from marking a vehicle as Disposed while it is Rented. (Note that since this validation appears for both fields, a user will receive a validation prompt with two duplicate messages if trying to dispose of a rented vehicle.)

If geRecord.Fields.Item("DateDisposed").IsDirty _ 
                           AndAlso geRecord.GetValue("VehicleStatus").ToString = "Rented" Then 
               oResult.Success = False 
               oResult.Message = "This Vehicle can not be disposed while its status is rented." 
Else 
               If geRecord.GetValue("DisposalMethod").ToString <> "N/A" _ 
                                        AndAlso (IsDBNull(geRecord.GetValue("DateDisposed")) _ 
                                               OrElse geRecord.GetValue("DateDisposed").ToString = "") Then 
                           oResult.Success = False 
                           oResult.Message = "If this Vehicle has been disposed, both the method" & _ 
                                               " and date of disposal must be specified." 
               Else 
                          oResult.Success = True 
               End If 
End If

 

The full text of the script for the DisposalMethod field appears below. The field validation fails if the DateDisposed is set (i.e., not blank or NULL) and the Disposal Method is set to N/A. Also, the script prevents a user from marking a vehicle as Disposed while it is Rented. (Note that since this validation appears for both fields, a user will receive a validation prompt with two duplicate messages if trying to dispose of a rented vehicle.)

If geRecord.Fields.Item("DisposalMethod").IsDirty _ 
                             AndAlso geRecord.GetValue("VehicleStatus").ToString = "Rented" Then 
                oResult.Success = False 
                oResult.Message = "This Vehicle can not be disposed while its status is rented." 
Else 
                If Not IsDBNull(geRecord.GetValue("DateDisposed")) _ 
                                       AndAlso geRecord.GetValue("DateDisposed").ToString <> "" _ 
                                       AndAlso geRecord.GetValue("DisposalMethod").ToString = "N/A" Then 
                             oResult.Success = False 
                             oResult.Message = "If this Vehicle has been disposed, both the method" & _ 
                                                           " and date of disposal must be specified." 
                Else 
                             oResult.Success = True 
                End If 
End If

Copyright © 2014-2017 Aptify - Confidential and Proprietary