Skip to 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

Field Type Required Description Validators
user_id str Recipient user ID -
subject str Notification subject/title maxLen: 255
message str Full notification message -
notification_type str Notification type (info, success, warning, error, etc.) -
read bool Whether the notification has been read -
doctype None Related DocType (e.g., Invoice) -
document_id None Related document ID -
timestamp datetime When the notification was created (UTC) -
from_user None User who triggered the notification -
metadata None Additional notification data -
Role Create Delete Read Write
All
System Manager
Setting Value
Submittable False
Track Changes True

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