DODEFAULT() RETURN THISFORM.ValidAOP(v_tUrineAnalysis.cPusCells, "Pus Cells")cRBC.Valid()
DODEFAULT() RETURN THISFORM.ValidAOP(v_tUrineAnalysis.cRBC, "R.B.C.")... there are a lot of similar calls here
LPARAMETERS tcValue, tcMsg LOCAL llRetVal IF THISFORM.botUrineAnalysis.ValidAOP(tcValue, tcMsg) llRetVal = .T. ELSE THISFORM.ShowErrorMsg(THISFORM.botUrineAnalysis.GetErrorMsg()) llRetVal = .F. ENDIF RETURN llRetValbo_tUrineAnalysis.ValidAOP()
LPARAMETERS tcReading, tcMsg LOCAL llRetVal IF INLIST(tcReading, "A", "O", "P") llRetVal = .T. ELSE THIS.AddToErrorMsg("Please enter A for Absent, O for Occasional or P for Present for " + tcMsg) llRetVal = .F. ENDIF RETURN llRetVal3. Put the same validations in the BeforeSaveValidation() of the Business Object calling respective routines for all the required fields. This will raise the point when new fields are added in a hurry on the form the BO.BeforeSaveValidation() may be missed out. This here cannot be avoided as a few fields are wihtout any valid clause and the user may press Ctrl+S to save the record thus the field.valid() wouldn't fire. Also please note repetition of constants like " Pus Cells" and "R.B.C." in Valid() and here (I can use the Captions defined in this tables).
LOCAL llRetVal llRetVal = DODEFAULT() IF "URM"$UPPER(v_LKtPatients.cTest) ... there are a lot of similar calls here IF !THIS.ValidAOP(v_tUrineAnalysis.cPusCells, "Pus Cells") llRetVal = .F. ENDIF IF !THIS.ValidAOP(v_tUrineAnalysis.crbc, "R.B.C.") llRetVal = .F. ENDIF ... there are a lot of similar calls here ENDIF RETURN llRetValNow to avoid the above, an idea that I got was to put the valid() call straight in the table using Field Validation Rule. Now the problem is that the actual validation is done in the BO.methods(), if I use a BO call here then I guess browsing through such tables outside the app will become impossible.