Imagine you want to avoid saving a record of a table if a particular condition is met.
You must access table and use ValidateWrite method

Only one record can have this checkbox set to TRUE.
If the use tries to set as TRUE another record the record cannot be saved.
We will use the ValidateWrite method of the table in order to extend the logic globally, but if you want to use the logic only on a form you can use the ValidateWrite () on the Form DataSource
So use this code
public boolean validateWrite()
{
boolean ret;
//Prevent from saving if DefaultRule is already valorized
ERAWriteOffRule eraWriteOffRule;
ret = super();
//Prevent from saving if DefaultRule is already valorized
select eraWriteOffRule
where eraWriteOffRule.DefaultRule == true;
if(eraWriteOffRule && eraWriteOffRule.RecId != this.RecId)
{
ret = checkFailed("@$AB164");
}
return ret;
}
This is the result
