✏️ Explanatory Question
The validateWrite() method is a standard method of a form data source, which is called when a user attempts to save a record to determine whether data is valid and ready to be written.
Example
You have a custom form with a table named TrainingMaster. The table has a date field named TrainingDate. No backdated training data should be allowed.
The following code pattern can be a way to achieve this result:
[DataSource]
class TrainingMaster
{
public boolean validateWrite()
{
boolean ret;
ret = super() && (TrainingMaster.TrainingDate >= today());
return ret;
}
}
Note
You don’t want to let the validateWrite() method fail without a message regarding why. A best practice would be to throw an error with a specific message rather than using the Boolean return of the if statement.