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
| 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 | str | None | Related DocType (e.g., Invoice) | |
| document_id | str | None | Related document ID | |
| timestamp | datetime | When the notification was created (UTC) | - | |
| from_user | str | None | User who triggered the notification | |
| metadata | dict[str, Any] | None | Additional notification data |
Permissions
| Role | Create | Delete | Read | Write |
|---|---|---|---|---|
| All | ✓ | ✓ | ✓ | |
| System Manager | ✓ |
Configuration
| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Controller hooks are implemented in *_controller.py files.
Available lifecycle hooks:
validate()- Called before save, raise exceptions for validation errorsbefore_insert()- Called before inserting a new documentafter_insert()- Called after successfully insertingbefore_save()- Called before saving (insert or update)after_save()- Called after savingbefore_delete()- Called before deletingafter_delete()- Called after deleting