Skip to content

allowCalculateOverride does not reliably preserve manual overrides with Logic or Calculated Values #639

@xacsreportmanagerrenganathan-lang

Description

When using allowCalculateOverride: true, manually overridden values should be preserved. However, both Logic (change event) and Calculated Value mechanisms override the user-entered value during form load or recalculation.

This makes it difficult to implement dependent fields that allow users to override automatically calculated values.


Scenario

Two datetime fields:

  • riskInceptionDate
  • riskExpiryDate

Expiry should be automatically calculated as:

moment(data.riskInceptionDate).add(365, 'days')

but users must be able to manually override the expiry date.


Attempt 1 – Using Logic (Change Event)

Logic on riskInceptionDate:

if (data.riskInceptionDate) {
  data.riskExpiryDate = moment(data.riskInceptionDate)
    .add(365, 'days')
    .toDate();
}

riskExpiryDate configuration:

"allowCalculateOverride": true

Problem

When loading submission data:

  1. Form loads submission values
  2. setValue() fires change events
  3. Logic runs again
  4. riskExpiryDate is recalculated
  5. The manually overridden value is overwritten

Attempt 2 – Using Calculated Value

Calculated Value for riskExpiryDate:

if (data.riskInceptionDate) {
  value = moment(data.riskInceptionDate)
    .add(365, 'days')
    .toDate();
}

allowCalculateOverride enabled.

Problem

Calculated Value continues to recompute when the form recalculates, which overwrites the manually overridden value when the form loads or when dependent fields update.


Actual Behavior

Manual overrides are not preserved consistently when:

  • the form loads submission data
  • dependent fields trigger recalculation
  • logic runs through change events

Expected Behavior

When allowCalculateOverride is enabled:

  • Logic or Calculated Values should not overwrite an existing user-entered value.
  • Manual overrides should persist after form reload or recalculation.

Impact

This prevents reliable implementation of common patterns such as:

  • auto-calculating policy expiry dates
  • auto-populating dependent fields while still allowing user overrides

Developers must implement complex workarounds (flags, hidden fields, conditional checks) to preserve overrides.


Environment

  • Form.io version: "@formio/js": "^5.2.5", "@formio/react": "^6.1.2"
  • Components affected: datetime, but likely applies to other calculated fields as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions