You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the following signature to send the simple notification with title and description
51
39
52
-
When you run `cds add notifications`, it will add `notificationstype.json` file with template for a notification type in the project root folder. You can add the notification types in the `notificationtype.json` file for sending the custom notification types.
40
+
```js
41
+
alert.notify({
42
+
recipients: [ ...supporters() ],
43
+
priority:"HIGH",
44
+
title:"New high priority incident is assigned to you!",
45
+
description:"Incident titled 'Engine overheating' created by 'customer X' with priority high is assigned to you!"
46
+
});
47
+
```
53
48
54
-
#### Notification Type Prefix
49
+
***priority** - Priority of the notification, this argument is optional, it defaults to NEUTRAL
50
+
***description** - Subtitle for the notification, this argument is optional
55
51
56
-
To make notification types unique to the application, prefix is added to the type key. By default, `application name` is added as the prefix. You can update the `prefix` if required.
52
+
## Use Notification Types
57
53
58
-
### Add Notification Types
54
+
### 1. Add notification types
59
55
60
-
If you want to send custom notifications in your application, you can add the notification types in the `notificationtype.json` file.
56
+
If you want to send custom notifications in your application, you can add the notification types in the `srv/notification-types.json` file.
61
57
62
-
Sample: If you want to send the notification when the new incident is reported, you can modify the `notificationtypes.json` as below:
58
+
Sample: If you want to send the notification when the incident is resolved, you can modify the `srv/notification-types.json` as below:
title:"New high priority incident is assigned to you!",
107
-
description:"Incident titled 'Engine overheating' created by 'customer X' with priority high is assigned to you!"
108
-
});
109
-
```
92
+
## API Reference
93
+
94
+
***recipients** - List of the recipients, this argument is mandatory
95
+
***type** - Notification type key, this argument is mandatory
96
+
***priority** - Priority of the notification, this argument is optional, it defaults to NEUTRAL
97
+
***data** - A key-value pair that is used to fill a placeholder of the notification type template, this argument is optional
98
+
99
+
## Test-drive Locally
100
+
In local environment, when you publish notification, it is mocked to publish the nofication to the console.
101
+
102
+
<imgwidth="700"alt="Notify to console"style="border-radius:0.5rem"src="_assets/notifyToConsole.png">
103
+
104
+
## Run in Production
105
+
106
+
#### Notification Destination
107
+
108
+
As a pre-requisite to publish the notification, you need to have a [destination](https://help.sap.com/docs/build-work-zone-standard-edition/sap-build-work-zone-standard-edition/enabling-notifications-for-custom-apps-on-sap-btp-cloud-foundry#configure-the-destination-to-the-notifications-service) configured to publish the notification. In the `package.json` by default destination name `SAP_Notifications` is added, you can modify the destination name that you are configuring.
109
+
110
+
#### Integrate with SAP Build Work Zone
111
+
112
+
Once application is deployed and [integrated with SAP Build Work Zone](https://github.com/cap-js/calesi/tree/main/samples/notifications), you can see the notification under fiori notifications icon!
Notifications plugin configures `srv/notification-types.json` as default notification types file. If you are using different file, you can update the file path in `cds.env.requires.notifications.types`
123
+
124
+
### Custom Notification Type Prefix
125
+
126
+
To make notification types unique to the application, prefix is added to the type key. By default, `application name` is added as the prefix. You can update the `cds.env.requires.notifications.prefix` if required.
127
+
128
+
### Low-level Notifications API
110
129
111
-
#### Custom Notifications
112
130
You can use these two signature to send the custom notification with pre-defined notification types.
113
131
114
-
##### With standard parameters
132
+
#### With pre-defined parameters
133
+
134
+
By using this approach you can send notifications with the predefined parameters - recipients, data, priority, type and other parameters listed in the [API documentation](https://help.sap.com/docs/build-work-zone-standard-edition/sap-build-work-zone-standard-edition/developing-cloud-foundry-applications-with-notifications)
115
135
116
-
By using this approach you can post a notification by providing different parts of the notification object grouped in related units
***recipients** - List of the recipients, this argument is mandatory
164
-
***type** - Notification type key, this argument is mandatory
165
-
***priority** - Priority of the notification, this argument is optional, it defaults to NEUTRAL
166
-
***properties** - A key-value pair that is used to fill a placeholder of the notification type template, this argument is optional
167
-
***navigation** - All navigation related parameters, this argument is optional
168
-
***payload** - The rest parameters that can be passed, this argument is optional
162
+
#### Passing the whole notification object
169
163
170
-
##### Passing the whole notification object
164
+
By using this approach you need to pass the whole notification object as described in the [API documentation](https://help.sap.com/docs/build-work-zone-standard-edition/sap-build-work-zone-standard-edition/developing-cloud-foundry-applications-with-notifications)
171
165
172
-
By using this approach you need to pass the whole notification object as described in the API documentation
In local environment, when you publish notification, it is mocked to publish the nofication to the console.
202
-
203
-
<imgwidth="1300"alt="Notify to console"style="border-radius:0.5rem;padding:1rem;background:rgb(242424)"src="_assets/notifyToConsole.png">
204
-
205
-
#### In Production Environment
206
-
207
-
##### Notification Destination
208
-
209
-
As a pre-requisite to publish the notification, you need to have a [destination](https://help.sap.com/docs/build-work-zone-standard-edition/sap-build-work-zone-standard-edition/enabling-notifications-for-custom-apps-on-sap-btp-cloud-foundry#configure-the-destination-to-the-notifications-service) configured to publish the notification. In the `package.json` by default destination name `SAP_Notification` is added, you can modify the destination name that you are configuring.
210
-
211
-
##### Integrate with SAP Build Work Zone
212
-
213
-
Once application is deployed and [integrated with SAP Build Work Zone](https://github.com/cap-js/calesi/tree/main/samples/notifications), you can see the notification under fiori notifications icon!
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/change-tracking/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
220
194
221
-
222
-
### Code of Conduct
195
+
## Code of Conduct
223
196
224
197
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
225
198
226
-
227
199
## Licensing
228
200
229
201
Copyright 2023 SAP SE or an SAP affiliate company and contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cap-js/change-tracking).
0 commit comments