Objects and versions

View as Markdown

Everything stored in a vault is an object of some object type: a document, a customer, a project. Changes are made in new versions of the object; older versions stay readable, and most read calls ask for one specific version.

Identity: ObjID and ObjVer

ObjID   type: 0                                   object type (0 = Document)
        item_id { internal_id: 358 }              object ID within that type
ObjVer  obj_id { type: 0 item_id { internal_id: 358 } }
        version { type: OBJ_VER_VERSION_TYPE_SPECIFIC internal_version: 3 }

Latest or specific version

ObjVerVersion.type says what internal_version means. Versions returned by the server are always OBJ_VER_VERSION_TYPE_SPECIFIC with a number. Requests should send the same:

"Latest" means the latest checked-in version, except for the user who has the object checked out: with allow_checked_out true (and in GetObjectInfo), that user gets the checked-out version.

Check-out and check-in

An object is changed through a checked-out version: a new version that only the user who checked it out can see and edit until it is checked in.

AddObject(check_in: false)   v1 checked out to you        others: "Not found."
CheckIn(v1)                  v1 checked in                everyone with access sees v1
CheckOut                     v2 checked out to you        others still see v1
SetProperties(v2), ...       still v2                     edits do not add versions
CheckIn(v2)                  v2 checked in                (or UndoCheckout(v2): v2 is discarded)
SetProperties(v2, allow_modifying_checked_in_object: true)
                             v3 checked in in one call    check-out, change, check-in

The sequence above was run against the Sample Vault. Points to remember:

Files: single-file and multi-file documents

Files belong to object versions; there is no file without an object. Object types whose OBJTYPEFLAGS.can_have_files is true (documents, for example) can carry files, and their objects must have property 22 (Single file):

Creating a document without property 22 fails with 'The mandatory property value "Single file" is missing.' Each File in ObjectVersion.files has a FileVer: a file ID and a file version. Files have versions of their own, separate from the object's version numbers. How to download and upload file content is described in Files.

Deleted and destroyed

Deleted (RemoveObject) Destroyed (DestroyObject)
Data kept; ITEMFLAGS.is_deleted set removed permanently
Normal users "Not found."; not in search results "Not found."
Users with see_deleted_objects visible; found by searches without a "not deleted" condition "Not found."
Way back UndeleteObject none

Undeleting and destroying need the vault-level rights undelete_objects and destroy_objects (see Permissions), and seeing deleted objects needs see_deleted_objects. In the Sample Vault a normal user could delete an object but got "Access denied. You do not have the access rights required by this operation." for undelete and destroy; a vault administrator could do both. DestroyObject takes all_versions true with version type OBJ_VER_VERSION_TYPE_ALL, or a single version.

GUIDs and external IDs

Store the ObjID (or the GUID) of an object, not its title or a version number: titles change, and every edit makes a new version.