Ga naar hoofdinhoud

useRestoreVersion

Restore a record to the state after one audit-trail entry, through OpenRegister's revert route (POST /apps/openregister/api/objects/{register}/{schema}/{id}/revert with { auditTrailId }). OpenRegister saves the restore as a new version, so nothing is lost. Backs the restore button of CnAuditTrailTab.

import { useRestoreVersion } from '@conduction/nextcloud-vue'

const { restore } = useRestoreVersion({ apiBase: '/apps/openregister/api' })
const result = await restore({ register: 'permits', schema: 'permit', objectId, auditTrailId: 42 })
// result: { ok, status, record, message }

message is a fixed sentence, never the server's own text:

OutcomeMessage
200(empty, record holds the restored record)
403You cannot restore this record.
423This record is locked by {name}. (or "…by someone else." without a holder)
404This record no longer exists.
anything else, or a network failureThe record could not be restored.

Pass object (the record as the page holds it) so a 423 can name the lock holder through lockHolder().