Highlighting coverage term in popup with validation error
You can link to and highlight a coverage term, or other dynamically derived, field that fails class-based validation in a popup. The linking and highlighting works if validation is called when the popup is open.
You can find an example in the Businessowners line in a building validation class,
BOPBuildingValidation, the checkIncomeExpenseTerm
method. For the Ordinance or Law coverage, the validation code checks
that if the BOP Ordinance or Law - Income/Expense coverage term is
selected, then at least one limit coverage term has a value. Because these fields are
dependent upon one another, you cannot use field-level validation. If class-based validation
fails, the method calls
Result.addFieldError:
Result.addFieldError( _building, "BOPOrdinanceCov.BOPOrdLawIncomeExpenseTerm.Value", TC_DEFAULT,
<display key>, "BOPBuildings")The signature for addFieldError
is:
function addFieldError(problematicBean : KeyableBean,
fieldPath : String, level : ValidationLevel,
reason : String, wizardStepId : String)The method uses the problematicBean as the root of a field path, and appends the fieldPath. The path is the field to highlight in the PCF file.
The problematicBean parameter must be a concrete entity type, but
coverages and coverage terms are abstract. Therefore use the coverable,
_building, for the problematicBean.
If you have the coverage, or other clause, but not the coverable, you can get the coverable
from the
coverage:
var bopOrdCov = _building.BOPOrdinanceCov // bopOrdCov is a coverage
Result.addFieldError(bopOrdCov.BOPBuilding , "BOPOrdinanceCov.BOPOrdLawIncomeExpenseTerm.Value", ...)