MD.OFFICE
FAL

2026-03-06

Prevent Deleting Fields Referenced in Formulas / Validation Rules (Dynaforms)

  • Feature Enhancement: Added a deletion guard that prevents users from deleting a field on the canvas if its jsonKey is referenced anywhere in the form — in formulas, formula libraries, rule conditions, or validation rules.
  • New method isFieldReferencedInFormulas(jsonKey) added to DynaformService. It reuses the existing traverseCanvasElements utility (no new traversal loop) with a visitor that checks all 4 reference types in a single pass:
    1. el.formula — legacy formula on formula-type fields
    2. el.formulaLibrary[].formula — formula library entries
    3. el.rules[].condition — rule condition keys (uses direct equality via a recursive checkConditionTree helper, since conditions store keys as standalone values)
    4. el.validationRules[].formula — validation rules on any field type (uses word-boundary regex since keys are embedded in expression strings)
  • Returns an array of referencing element labels (empty = safe to delete).
  • Guard added in CenterPanelComponent.deleteElement(): Calls isFieldReferencedInFormulas before proceeding. If the field is referenced, shows an error toast listing the referencing elements and blocks the deletion. Follows the same pattern as the existing deleteFormulaFromLibrary / isFormulaInUse guard.