Notification
A sub namespace of Service, exclusive for notification operations
//accessing to service.notification methods
SW.Service.Notification.{methodName}
get
Description
This method can be used to get notifications (paginated). getAll remains available as an alias for backward compatibility.
Method(s)
1 function get(params: {
2 skip: number,
3 take: number,
4 filter: string,
5 includeRead: boolean
6 } = {
7 skip: 0,
8 take: 20,
9 filter: "",
10 includeRead: true
11 }): Promise<NotificationPagedList>
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
skip | number | false | 0 | Number of records to skip (pagination offset) |
take | number | false | 20 | Number of records to return (page size) |
filter | string | false | "" | Search text |
includeRead | boolean | false | true | Include already read notifications |
Basic Usage
SW.Service.Notification.get();
getGroupedByDocument
Description
This method can be used to get notifications grouped by document.
Method(s)
1 function getGroupedByDocument(params: {
2 skip: number,
3 take: number
4 } = {
5 skip: 0,
6 take: 20
7 }): Promise<Notification[]>
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
skip | number | false | 0 | Number of records to skip (pagination offset) |
take | number | false | 20 | Number of groups to return |
Basic Usage
SW.Service.Notification.getGroupedByDocument();
getUnreadCounter
Description
This method can be used to get the number of unread notifications.
Method(s)
1 function getUnreadCounter(): Promise<number>
Basic Usage
SW.Service.Notification.getUnreadCounter();
markAsRead
Description
This method can be used to mark notifications as read until a given date.
Method(s)
1 function markAsRead(untilDate: Date): Promise<any>
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
untilDate | Date | true | Mark as read until this date |
Basic Usage
SW.Service.Notification.markAsRead(new Date());
markAsReadByDocument
Description
This method can be used to mark notifications as read from a given document.
Method(s)
1 function markAsReadByDocument(objectId: string, objectType: string): Promise<any>
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
objectId | string | true | Document id | |
objectType | string | true | Document name |
Basic Usage
SW.Service.Notification.markAsReadByDocument('jobId', 'job');
send
Description
This method can be used to send a new notification.
Method(s)
1 function send(text: string, documentTypeName: string, documentId: string, userIdsToNotify: string[]): Promise<any>
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
text | string | true | Notification text | |
documentTypeName | string | true | Document name | |
documentId | string | true | Document id | |
userIdsToNotify | string[] | true | Users to receive the notification |
Basic Usage
SW.Service.Notification.send('New notification text', 'Deliverable', 'jobId', ['userId', 'userId']);
sendToBrowser
Description
This method can be used to display a browser notification directly in the UI.
Method(s)
1 function sendToBrowser(browserNotification: Interface.BrowserNotification): void
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
browserNotification | Interface.BrowserNotification | true | Browser-compatible notification payload |
Basic Usage
SW.Service.Notification.sendToBrowser({
title: 'Workflow Alert',
message: 'Your proof is ready for review.'
});