Who this is for. Anyone wiring a job to content, commerce or member records. Afterwards you can pick the right entity and method, narrow the trigger, and detect what actually changed.
The methods
An Entity Event Trigger names an entity (pages, posts, products, orders, form submissions, people, the records of a custom entity type, and many more) and a method. Every entity has the first three; the others belong to particular entities or need a setting.
| Method (admin label) | Fires when |
|---|---|
CreateRecord (Created) | A record is saved for the first time, from the admin, the API or a front-end form |
UpdateRecord (Updated) | A saved record changes, once per save. Also when a scheduled publish or unpublish date passes, with no save |
DeleteRecord (Deleted) | A record is deleted |
StartEditingRecord (Editing) | Someone opens a record for editing in the admin, only when the Globals setting Log record editing start is on, and at most once per record every 10 seconds (Log record editing start delay) |
Completed | Form submissions: the submission is completed, once, including the last step of a multi-step form |
Abandoned | Carts: a background check finds the cart abandoned |
SendReceipt (Send Receipt) | Invoices: an administrator uses Send receipt on the invoice in the admin |
Login | Users: someone signs in with a password or passkey through the platform's login, only when the Globals setting Log login event is on |
ExportPDF (Export PDF) | Books: a PDF export of the book is requested |
BackInStock (Back in stock) | Products and variants: the available stock rises above the threshold that shoppers' stock interests wait for |
A trigger can be narrowed. Record limits it to one record (not offered for Created, which has no record yet). The parent field limits it to the children of one record: the submissions of one form, the posts of one blog, the pages under one page. Every listed trigger is in the job event reference.
When the job runs
An entity event never runs a job inside the save. The save puts the event on a queue; a background worker matches it against every published job with a trigger for that entity and method (and, if the job has a site, only for records of that site), and queues a run for each. The run starts a moment later and always runs in the background, whatever the job's Synchronous execution setting.
That delay has a consequence. event.getRecord() loads the record when a template first asks for it, so it shows the record as it is then, which after a quick second edit is not how it was at the event.
What the run receives
On event | Returns |
|---|---|
getEntityName(), getMethod(), getRecordId() | Which entity, which method, which record |
getRecord() | The record, unpublished or not; empty after a delete |
getPreEventData() | The values captured before the change, if the trigger asked for any (below) |
What an update can see of the previous values
Nothing, unless the trigger asks. List the fields you need under the trigger's Pre-Event properties, offered for Updated and Deleted, in the API's properties form with the API's field names: {published, price}, {financialStatus}. The platform reads them just before the change and passes them as getPreEventData(). Without that list, the run sees only the record as it now is, with no earlier value to compare.
A delete is the other case that needs it. By the time the run starts the record is gone, so getRecord() is empty. getPreEventData() always holds its id (and parentRecordId for a record with a parent); anything else the job needs, such as an externalId to tell another system, must be listed as a Pre-Event property on the Deleted trigger.
Detecting that a record went live
There is no published event. A record published at once arrives as UpdateRecord with an empty published before and a date after. A record whose scheduled date passes also arrives as UpdateRecord, but nothing was saved: the snapshot is taken at that moment, so published is the same date before and after. A condition that only compares the two misses every scheduled go-live, and one that only checks for a date fires when an editor schedules a page, before it is live. With {published} as the Pre-Event property, this template condition carries on in both real cases and in neither false one: