Skip to main content

ActivityLog

Activity log entry DocType.

Stores an immutable audit record of a user action on a document.
Once created, activity logs should never be modified or deleted.

Attributes:
user_id: ID of the user who performed the action
action: Type of action ("create", "read", "update", "delete")
doctype: Name of the affected DocType
document_id: ID of the affected document
timestamp: When the action occurred (auto-set)
changes: Field changes for updates (old/new values)
metadata: Additional context (request_id, ip, user_agent)

Example:
log = ActivityLog(
user_id="user-001",
action="create",
doctype="Todo",
document_id="TODO-001",
)

Source: activity_log.py

Fields

FieldTypeRequiredDescriptionValidators
user_idstrID of the user who performed the actionminLen: 1
actionstrType of action: create, read, update, deletepattern: `^(create
doctypestrName of the affected DocTypeminLen: 1
document_idstrID of the affected documentminLen: 1
timestampdatetimeWhen the action occurred (UTC)-
changesdict[str, Any]NoneField changes for updates: {field: {old: x, new: y}}
metadatadict[str, Any]NoneAdditional context: request_id, ip, user_agent, etc.

Permissions

RoleCreateDeleteReadWrite
All
System Manager

Configuration

SettingValue
SubmittableFalse
Track ChangesTrue

Controller

Controller hooks are implemented in *_controller.py files. Available lifecycle hooks:

  • validate() - Called before save, raise exceptions for validation errors
  • before_insert() - Called before inserting a new document
  • after_insert() - Called after successfully inserting
  • before_save() - Called before saving (insert or update)
  • after_save() - Called after saving
  • before_delete() - Called before deleting
  • after_delete() - Called after deleting