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
Section titled “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 | 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 | - |
Permissions
Section titled “Permissions”| Role | Create | Delete | Read | Write |
|---|---|---|---|---|
| All | ✓ | ✓ | ✓ | |
| System Manager | ✓ |
Configuration
Section titled “Configuration”| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Section titled “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