docs
/
AI skills

Bring back deleted records, go back a version, and find who changed what

What really lands in Trash (and what is gone for good), restoring a record and what doesn't come back with it, permanent deletes, going back to an earlier version from History, and answering "who changed or deleted this, and when" from the record, its History and the Activity Feed.

Three places answer these questions, and they keep different things:

PlaceWhat it keepsFor how long
Trash (trash records)A full copy of each deleted record, with sourceDatatype, deletedBy and historyDate (when it was deleted)Until someone deletes it from Trash. Nothing empties it on a timer.
History (history records)Earlier versions of one record, each with when and who10 versions per record; more for audited types (below). Deleted with the record.
Activity Feed (activity records)One line per event: deletes, restores, sign-ins, sign-ups, some changesUntil deleted. Audit lines stay after their record is deleted.

For a page (live copy, publishing, its History tab in Build Studio), see Publish, unpublish and restore a page. This skill covers every other kind of record.

Most kinds of record never reach Trash. A delete keeps a Trash copy only when the record's collection keeps versions (enableVersioning, appengine history/history.service.ts 127–137, 298–299). Today that is: automation, campaign, collection, company, customer, page, post, sf_product, site, user, plus the audited types that always keep one: sf_order, bm_payroll_profile, bm_compensation_change, bm_timesheet, bm_clock_event, journal_entry. Everything else (leads, tickets, events, reservations, invoices, forms, templates, groups, dashboards…) and every custom collection with versioning off (the Collection builder default) is gone for good when deleted. The Activity Feed still records who deleted it. Tested: a deleted message template left no Trash copy.

Ask first

  • Which record? Its name, email, SKU or number, and its kind (customer, product, order…). "The thing I deleted this morning" is enough to search Trash and the log.
  • Bring it back, or remove it for good? A permanent delete can't be undone.
  • Go back to which version? By date and time, from the list in step 3. Show what changes before restoring.
  • For "who did it": which record, or what period? One record's story, or everything one person did today.

Steps

1. Trash: find the deleted record

On screen: Trash in the sidebar (/trash). Columns: Name, Type, Deleted by, Deleted. The list is sorted by the record's own last change, not by when it was deleted, so an old record deleted today may sit far down.

Through the API: repo_find on trash, newest delete first:

{ "datatype": "trash", "query": { "sourceDatatype": "customer", "data.email": "[email protected]" }, "options": { "sort": "historyDate", "sortType": -1 } }
Field on a Trash rowWhat it is
skThe deleted record's own id. Restore and permanent delete use this.
_idThe Trash row's own id. Use it to pick one copy when the record was deleted more than once.
sourceDatatypeThe kind of record (sf_product, customer…)
deletedByThe email of the person (or the person the AI acted for) who deleted it
historyDateWhen it was deleted (milliseconds)
dataThe record as it was at the moment of deletion

Nothing found? Check the warning above: if its kind doesn't keep versions, there is no copy. Go to step 4 to say who deleted it and when.

Hands on: the record's sk and its sourceDatatype. Check: the row on the Trash screen shows the same name, type and deleter.

2. Trash: restore it, or delete it for good

Before restoring, check that nothing has taken its place: a new customer with the same email, a product with the same SKU, a page with the same slug. A restore writes the record back as it was and doesn't check for clashes, so you would end up with two.

Restore. On screen: the row's Restore. Through the API: call_appengine POST /repository/trash-restore with a list of ids:

["<record sk>"]

It answers with the restored records (an empty answer means nothing was restored: no Trash copy with that id). Tested (appengine history/history.service.ts 360–393):

  • The record comes back under its old id, with its data as it was when deleted. A restored customer signs in with their old password.
  • Its Trash row goes; the Trash entry for every earlier delete of the same record goes too. To pick one copy, send the Trash row's _id instead of the sk.
  • It carries restoredDate (and keeps deletedBy and historyDate) on the record, so you can tell later that it was restored.
  • An entry Restore " "" restored from Trash" is added to the Activity Feed, by the person who restored it.
  • If a record with that id already exists, nothing is restored and its Trash copies are dropped.

What does not come back, because the delete removed it (appengine repositories/repository.crud.service.ts 1810–1857):

Lost on deleteSo after a restore
Its HistoryIt has no earlier versions. History starts again at the next save.
A page's or post's live copyPublish it again
Tasks it owned, and its schedulesRecreate them
Its likes, views and other non-audit activityGone. The audit lines (created, changed, deleted, restored) stay.
A person's second factors and trusted devices (customer or user)They sign in with their password and set up two-step sign-in again

A restore is written straight back, not created again, so automations that start when a record is created don't run for it (history.service.ts 388). No email goes to the person. A customer or user who was removed was emailed "Your account has been removed" at the delete; nothing tells them they're back. Tell them yourself if they should know.

Stop: restoring puts the record back in every list, search and, for a page or product, possibly on the site. Name the record, its type and who deleted it when, and wait for yes.

Delete for good. On screen: the row's Delete, or select several rows and Delete. Through the API: call_appengine DELETE /repository/delete/trash/<record sk>, or POST /repository/delete/trash with ["<sk>", …]. It answers { "deleted": <count> }, or 404 Nothing in the trash with that id. An entry " "" permanently deleted from Trash" goes into the Activity Feed. There is no Empty Trash button; select the rows.

Stop: a permanent delete can't be undone. List what will go and wait for yes. "Empty the trash" covers only the rows you showed.

Hands on: the restored record's id, or the count deleted. Check: a restore: open the record on its own screen; it is gone from Trash. A permanent delete: it is gone from Trash.

3. History: go back to an earlier version

Which records keep versions:

RecordsVersions kept
customer, user, company, automation, campaign, collection, post, site, page10, on each save through the normal update. A change made with update-partial keeps none.
Audited types, every write from any routesf_order 20, sf_product 100, bm_payroll_profile 200, bm_timesheet 200, bm_compensation_change 100, bm_clock_event 50, manual journal_entry 100 (appengine history/audited-datatypes.ts 42–63)
A custom collectionOnly with enableVersioning switched on in the Collection builder

On an audited product, stock moves alone are not a version, and the same goes for a payroll profile's year-to-date totals.

On screen: the record's History tab: the product drawer, the order's History tab, and the History tab on other record forms. Changes at the top lists who changed what, old → new ("price 10 → 12"). Versions below lists each one by version number and date, with View and Restore (click twice).

Through the API:

  • call_appengine GET /repository/history/<datatype>/<id>?view=changes: each version as { id, at, by, version, kind, changes, old }, newest first. kind is created, changed or recorded (its history starts there). Bank account, routing and SSN values show only their last four. Tested.
  • GET /repository/history/<datatype>/<id>: the full versions, _id and data of each.
  • Restore: POST /repository/history/restore with { "datatype": "<datatype>", "id": "<record id>", "historyId": "<the version's _id>" }.

What a restore does (history.service.ts 219–239): the record's data, post, style and workflow become that version's and its version goes up by one. Tested on a product: price 30 went back to 20 as version 3. On an audited type the restore is itself kept as a new version, so you can go back again. On other types it is kept only from the next save.

A version restore adds no line to the Activity Feed, and the new version's by is the record's last writer, not necessarily who restored it. Say in the record's notes who restored it, if that matters.

Stop: a restore changes the live record at once: a product's price on the site, an order's lines. Show the changes (old → new) and wait for yes.

Hands on: the historyId restored and the record's new version. Check: open the record; the History tab's Changes list shows the step back.

4. Activity Feed: who did what, and when

On screen: Activity Feed under App Root (/activity-feed), also at Account › Logs (/logs). Figures for Total events, Today, Last 7 days and Errors; filters for Action, Record type, Status, Who and a date range; a search box. Clicking a record's name shows only that record's activity. The filters stay in the address, so a link reopens the same view (/activity-feed?owner=<record id>).

Through the API: call_appengine GET /analytics/activity-feed with any of owner=<record id>, type=delete,restore, datatype=customer, author=<email>, status=failed, errors=true, range=today|7d|30d|custom with from and to, q=<words>, tz=<time zone>, p and ps for paging. Each row has actionLabel, who, author, recordLabel, recordTitle, createdate and data.comment. Tested.

What is recorded (appengine repositories/audit-activity.ts, repository.crud.service.ts 1025–1035, 1476–1500, 1862–1871):

EventRecorded as
A person deletes a business record (any kind, Trash copy or not)Deleted, " "" deleted by "
Restore from Trash; permanent delete from TrashRestore / Deleted "… permanently deleted from Trash"
A save to a record whose collection has versioning on (customers, users, products, posts…)Updated, with each changed top-level field's old and new value in data.meta. Orders and payroll records are not in the feed: read their History.
A save to the business's setup (settings, translations, locations, password policy, roles, groups)Updated, naming the fields changed, never their values. Creating one is recorded too.
Sign-ins (success and failure, with device details in data.meta), sign-ups, password and email changesSigned in, Signed up… Failed sign-ins have status failed: use Errors only.
API keys created and changedBy their own service

Not recorded: creating an ordinary record (read created_by and createdate on it), a save to a record that doesn't keep versions, a version restore (step 3), and deletes the system makes itself.

For one record, put three things together:

  1. The record: created_by (or author) and createdate, modified_by and modifydate: who made it and who last saved it. On screen, its Audit tab.
  2. Its History (step 3): who made each change and what it was.
  3. The Activity Feed narrowed to it (owner=<id>): deletes, restores and logged changes, including after it was deleted.

For sign-ins, filter Action Signed in and Who. A person can see their own sign-ins and devices with GET /profile/security/login-history and GET /profile/security/devices.

Hands on: the answer: who, what, when, from which of the three. Check: the same rows on the Activity Feed screen, filtered the same way.

When it's done

Tell the person:

  • for a restore: what came back, under which id, what didn't come back with it (History, live copy, tasks, second factors), and that the restore is in the log;
  • for a permanent delete: what went, and that it can't be undone;
  • for a version restore: which version, what changed back, and the new version number;
  • for "who did it": the person, the time, the action, and where it was read (the record, its History or the log). Say plainly when the record's kind keeps no Trash copy or no History, so there is nothing more to find.

Open the record on its own screen, or the Activity Feed filtered to it.

What it can't do yet

  • Most kinds of record are deleted for good (warning at the top). Only collections that keep versions, and the audited types, go to Trash.
  • A restored record has no History, and its tasks, schedules, live copy and second factors don't come back.
  • Trash is sorted by the record's last change, not by when it was deleted. Sort by historyDate through the API.
  • A version restore isn't in the Activity Feed.
  • No Empty Trash button and no automatic emptying.
  • The Audit tab's Modified field is always empty. It reads a field the record doesn't have (modifiedate); the real one is modifydate.
  • Sign-in history for other people is read from the Activity Feed. There is no screen for a person's own sign-in history or devices.

Don'ts

  • Don't tell the person a deleted record is "in Trash" before you've found it there.
  • Don't restore over a clash (same email, SKU or slug now used by another record) without saying so first.
  • Don't purge from Trash, or empty it, without a yes on the rows you listed.
  • Don't delete a customer or user with the generic record delete; staff use their own Contacts and Users screens, which notify the person and clear their sign-in security.
  • Don't pass silent: true to repo_delete: it skips the log line and the cleanup.
  • Don't delete an order to "undo" it; cancel or refund it (Refund, cancel or return an order).
  • Don't restore a version without showing old → new first.
  • Don't delete Activity Feed entries; they are the audit trail.