Setyenv · Docs
  • English
  • Spanish
  • Chinese
  • Japanese
  • Arabic
  • German
  • French
  • Hindi
  • Indonesian
  • Italian
  • Dutch
  • Portuguese
  • Russian
  • Turkish

Events system

WP-PFManagement's event system is the backbone for automation. Every record creation, update, and deletion fires an event that workflows and external systems can react to.

Built-in system events

Event slugWhen it firesPayload
pfm.record.createdAfter a record is insertedFull record data
pfm.record.updatedAfter a record is updatedPrevious values + changes map
pfm.record.deletedAfter a record is deletedRecord sys_id and entity
pfm.entity.createdAfter an entity is createdEntity definition
pfm.entity.updatedAfter an entity definition changesOld + new entity definitions
pfm.entity.deletedAfter an entity is removedEntity slug
pfm.journal.createdAfter a journal entry is createdJournal entry data

Event payload (record.updated)

{
  "entity": "ticket",
  "record": { "sys_id": "...", "title": "Updated title", "status": "closed" },
  "previous": { "title": "Old title", "status": "open" },
  "changes": { "title": "Updated title", "status": "closed" }
}

The changes map only includes fields whose values actually changed. The previous snapshot includes all fields before the update.

Custom events

Register new events via REST: POST /pfm/v1/events/catalog

Fire events via REST: POST /pfm/v1/events/{slug}/fire

Custom events require the pfm_fire_events capability.

Workflow integration

Events automatically translate to WP-PFWorkflow triggers:

  • pfm.record.created → workflow trigger "Record created" for the entity
  • pfm.record.updated → workflow trigger "Record updated" for the entity
  • pfm.record.deleted → workflow trigger "Record deleted" for the entity

The trigger payload contains the full record data + event metadata.

Event log

GET /pfm/v1/events/log — queryable by slug, actor, record, time range. Stored in wp_pfm_event_log. Pruned daily to keep max 50,000 rows (configurable via pfm_event_log_max_rows option).