Skip to content

A condition-based compliance flag

When you need this

"Find rows that break a policy and flag them" — where the policy is more than one date vs now. Un-acknowledged custody after 7 days, over-allocated licences, missing documentation. Zero Java — one entity_compliance_config row run by engine-entity.compliance-sweep.

The file

metadata/seed-data/office-equipment-compliance-configs.json (real file):

json
{
  "entity": "entity_compliance_config",
  "keyFields": ["compliance_code"],
  "source": "office-equipment",
  "rows": [
    {
      "compliance_code": "checkout-acknowledgement-compliance",
      "source_entity": "oeq_checkout",
      "when_status_in": "CHECKED_OUT,DUE_SOON,OVERDUE",
      "condition_expr": "custody_acknowledged != true && daysBetween(checkout_date, now()) > 7",
      "set_field": "compliance_flag",
      "set_value": "NON_COMPLIANT",
      "active": true
    }
  ]
}

A row where condition_expr is true is non-compliant; the job sets compliance_flag = "NON_COMPLIANT" on it (idempotent — a row already flagged is skipped).

The expression language

The platform ExpressionEvaluator — the same one that powers formula fields and cross-field validation. In scope: the row's fields, now, and (if configured) related_count. Allowed: &&, ||, !, comparisons, arithmetic, and whitelisted functions (daysBetween, now, coalesce, …). Not allowed: ternary ?:, in, ^.

Variants

  • Related-count (cross-record) — add related_count_entity, related_count_key_field (FK back to the source id), related_count_status_in; then use related_count in the expression, e.g. related_count > entitlement_quantity.
  • Escalation (raise a row in another entity) — replace set_field/set_value with escalation_entity, escalation_dedupe_field (a numeric column holding the source id), field_map_json, escalation_template_json.

Also ship

  • the shared entity_compliance_config.json (additive), and
  • metadata/rules/ensure_compliance_sweep_job_registered.json (AFTER_CREATEensureEntityComplianceSweepJobRegistered).