Skip to main content

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>
ParameterTypeRequiredDefaultsDescription
skipnumberfalse0Number of records to skip (pagination offset)
takenumberfalse20Number of records to return (page size)
filterstringfalse""Search text
includeReadbooleanfalsetrueInclude 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[]>
ParameterTypeRequiredDefaultsDescription
skipnumberfalse0Number of records to skip (pagination offset)
takenumberfalse20Number 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>
ParameterTypeRequiredDefaultsDescription
untilDateDatetrueMark 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>
ParameterTypeRequiredDefaultsDescription
objectIdstringtrueDocument id
objectTypestringtrueDocument 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>
ParameterTypeRequiredDefaultsDescription
textstringtrueNotification text
documentTypeNamestringtrueDocument name
documentIdstringtrueDocument id
userIdsToNotifystring[]trueUsers 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
ParameterTypeRequiredDefaultsDescription
browserNotificationInterface.BrowserNotificationtrueBrowser-compatible notification payload

Basic Usage

SW.Service.Notification.sendToBrowser({
title: 'Workflow Alert',
message: 'Your proof is ready for review.'
});