set_history()

Adds a custom history entry to an object via std.SetHistory. The server creates an entry of type OBJECT_INFORMATION (action ID 31) in the object’s history table. This works for all object types (folders, registers, documents).

1. Signature

  • Sync

  • Async

ecm.dms.set_history(
    model: _ECMModelBase | int,
    info: str,
    object_type_id: int | None = None,
) -> None
await ecm.dms.set_history(
    model: _ECMModelBase | int,
    info: str,
    object_type_id: int | None = None,
) -> None

2. Parameters

Parameter Type Default Description

model

_ECMModelBase | int

 — 

Either an ECM model instance (its id is used) or a plain integer object ID.

info

str

 — 

The information text to store in the history entry.

object_type_id

int | None

None

The numeric object type ID. If None, the type is extracted from the model instance when available, or resolved via get_object_type_by_id() for plain integer IDs.

3. Return value

None.

4. Exceptions

Exception Condition

ValueError

model is a model instance with id set to None.

ECMNotFoundException

object_type_id is None and no object with the given ID exists on the server.

5. Examples

5.1. Add a history entry to a document

  • Sync

  • Async

doc = ecm.dms.get(InvoiceDocument, 12345)
ecm.dms.set_history(doc, "Processed by automated workflow")
doc = await ecm.dms.get(InvoiceDocument, 12345)
await ecm.dms.set_history(doc, "Processed by automated workflow")

5.2. Add a history entry by plain ID

  • Sync

  • Async

ecm.dms.set_history(12345, "Export completed", object_type_id=327685)
await ecm.dms.set_history(12345, "Export completed", object_type_id=327685)

5.3. Add history entries to all query results

  • Sync

  • Async

for folder in ecm.dms.select(InvoiceFolder).where(InvoiceFolder.Year == 2024).stream():
    ecm.dms.set_history(folder, "Marked for annual review")
async for folder in ecm.dms.select(InvoiceFolder).where(InvoiceFolder.Year == 2024).stream():
    await ecm.dms.set_history(folder, "Marked for annual review")

6. See also

  • history() — Read the modification history of an object