Skip to content

A cross-plugin offboarding fan-out

When you need this

"When an employee is separated, auto-create the follow-up records for everything they hold" — asset return requests, licence reclamations, access revocations. The trigger entity can belong to another plugin entirely. Zero Java, zero cross-plugin HTTP — one entity_cross_plugin_action_config row run by engine-entity.cross-plugin-action.

The file

metadata/seed-data/office-equipment-cross-plugin-configs.json:

json
{
  "entity": "entity_cross_plugin_action_config",
  "keyFields": ["action_code"],
  "source": "office-equipment",
  "rows": [
    {
      "action_code": "equipment-separation-return",
      "trigger_entity": "employee",
      "trigger_status_field": "employment_status",
      "trigger_status_in": "TERMINATED,SEPARATED",
      "trigger_key_field": "id",
      "related_entity": "oeq_checkout",
      "related_match_field": "employee_id",
      "related_status_in": "APPROVED,CHECKED_OUT,DUE_SOON,OVERDUE",
      "create_entity": "oeq_return",
      "create_dedupe_field": "checkout_id",
      "create_template_json": { "status": "REQUESTED", "reason": "EMPLOYEE_SEPARATION" },
      "create_field_map_json": { "equipment_id": "equipment_id", "employee_id": "employee_id" },
      "related_set_field": "status",
      "related_set_value": "RETURN_PENDING",
      "active": true
    }
  ]
}

How to read it

When an employee row's employment_status becomes TERMINATED or SEPARATED, the job finds every oeq_checkout for that employee_id in an active status, creates one oeq_return per checkout (deduped on checkout_id, which must be a numeric/long column), copies the mapped fields, applies the template, and sets the source checkout's status to RETURN_PENDING.

The rules that bite

  • create_dedupe_field must be a numeric column holding the related row's id — it's how the job avoids double-creating on the next tick.
  • The trigger_entity can be owned by any plugin; you just need its name and the status field.
  • Ship the shared entity_cross_plugin_action_config.json (additive) and an AFTER_CREATE register rule calling ensureEntityCrossPluginActionJobRegistered.