Skip to main content

Notification

Notification DocType.

Stores in-app notifications for users.

Attributes:
user_id: Recipient user ID
subject: Notification subject/title
message: Full notification message
notification_type: Type of notification (info, success, etc.)
read: Whether the notification has been read
doctype: Related DocType (optional)
document_id: Related document ID (optional)
timestamp: When the notification was created
from_user: User who triggered the notification (optional)
metadata: Additional notification data

Example:
notification = Notification(
user_id="user-001",
subject="New Comment",
message="John commented on your invoice.",
)

Source: notification.py

Fields

FieldTypeRequiredDescriptionValidators
user_idstrRecipient user ID-
subjectstrNotification subject/titlemaxLen: 255
messagestrFull notification message-
notification_typestrNotification type (info, success, warning, error, etc.)-
readboolWhether the notification has been read-
doctypestrNoneRelated DocType (e.g., Invoice)
document_idstrNoneRelated document ID
timestampdatetimeWhen the notification was created (UTC)-
from_userstrNoneUser who triggered the notification
metadatadict[str, Any]NoneAdditional notification data

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