From fac732ea8c6eadd74b56e8733efeca623a96b13a Mon Sep 17 00:00:00 2001 From: Eric P Date: Fri, 26 Jun 2026 14:55:26 +0200 Subject: [PATCH 1/3] Update Notification details --- plugins/index.md | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/plugins/index.md b/plugins/index.md index 251b3d857..481bc8df2 100644 --- a/plugins/index.md +++ b/plugins/index.md @@ -312,24 +312,41 @@ Available for: ## Notifications -The Notifications plugin provides support for publishing business notifications in SAP Build WorkZone. The client is implemented as a CAP service, which gives us a very simple programmatic API: +The Notifications plugin provides support for publishing business notifications in SAP Build Work Zone. Notification types are defined by annotating CDS events, which the plugin then intercepts and forwards automatically: -```js -let alert = await cds.connect.to ('notifications') -await alert.notify({ - recipients: [ ...supporters ], - title: `New incident created by ${customer.info}`, - description: incident.title +```cds +@notification: { + template: { + title : 'New incident: {{title}}', + publicTitle : 'New Incident', + subtitle : 'Created by {{customer}}', + groupedTitle : 'Incident Updates' + } +} +event IncidentCreated { + title : String; + customer : String; +} + +this.on('CREATE', 'Incidents', async req => { + await this.emit('IncidentCreated', { + title: req.data.title, + customer: customer.info, + recipients: [ ...supporters ], + }) }) ``` Features: -- CAP Services-based programmatic client API → simple, backend-agnostic -- Logging to console in development → fast turnarounds, minimized costs -- Transactional Outbox → maximised scalability and resilience -- Notification templates with i18n support -- Automatic lifecycle management of notification templates +- CAP service-based API — simple, backend-agnostic +- Notification types defined via CDS @notification annotations or JSON +- Auto-emit: annotated CDS events are forwarded to ANS automatically +- Email delivery via configurable delivery channels +- i18n support and dynamic priority for notification types +- Console logging in development — no external service needed +- Transactional outbox — maximised scalability and resilience +- Automatic registration and lifecycle management of notification types on startup Available for: From a706f2f82106b91e9897f4c76db25815f2c4b7e0 Mon Sep 17 00:00:00 2001 From: Eric P Date: Tue, 30 Jun 2026 09:51:12 +0200 Subject: [PATCH 2/3] Update index.md --- plugins/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/index.md b/plugins/index.md index 481bc8df2..13ff876d5 100644 --- a/plugins/index.md +++ b/plugins/index.md @@ -327,7 +327,9 @@ event IncidentCreated { title : String; customer : String; } +``` +```js this.on('CREATE', 'Incidents', async req => { await this.emit('IncidentCreated', { title: req.data.title, From 2a15501cb113951d204bb77c9c91c82740afffce Mon Sep 17 00:00:00 2001 From: Buse Halis Date: Wed, 1 Jul 2026 13:30:16 +0200 Subject: [PATCH 3/3] docs(notifications): add Java plugin support and update examples --- plugins/index.md | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/plugins/index.md b/plugins/index.md index 13ff876d5..1f2d28d81 100644 --- a/plugins/index.md +++ b/plugins/index.md @@ -324,12 +324,15 @@ The Notifications plugin provides support for publishing business notifications } } event IncidentCreated { - title : String; - customer : String; + title : String; + customer : String; + recipients : String; } ``` -```js +::: code-group + +```js [Node.js] this.on('CREATE', 'Incidents', async req => { await this.emit('IncidentCreated', { title: req.data.title, @@ -339,12 +342,51 @@ this.on('CREATE', 'Incidents', async req => { }) ``` +```java [Java] +@Autowired +private NotificationService notificationService; + +@After(event = CqnService.EVENT_CREATE, entity = Incidents_.CDS_NAME) +public void afterIncidentCreated(Incidents incident) { + IncidentCreated data = IncidentCreated.create(); + data.setTitle(incident.getTitle()); + data.setCustomer(incident.getCustomer()); + data.setRecipients("supporter@example.com"); + + IncidentCreatedContext ctx = IncidentCreatedContext.create(); + ctx.setData(data); + notificationService.emit(ctx); +} +``` + +::: + +Alternatively, for Java you can use declarative `@notifications` on entities to trigger notifications automatically without writing handler code: + +```cds [Java] +service IncidentService { + @notifications : [{ + type : 'IncidentCreated', + on : ['CREATE'], + recipients : $self.createdBy, + parameters : { + title : $self.title, + customer : $self.customer + } + }] + entity Incidents as projection on my.Incidents; +} +``` + Features: - CAP service-based API — simple, backend-agnostic -- Notification types defined via CDS @notification annotations or JSON +- Notification types defined via CDS @notification annotations +- Notification types defined via JSON (Node.js only) - Auto-emit: annotated CDS events are forwarded to ANS automatically - Email delivery via configurable delivery channels +- Email HTML templates for rich email notifications +- Batch notifications — emit multiple notifications in a single call - i18n support and dynamic priority for notification types - Console logging in development — no external service needed - Transactional outbox — maximised scalability and resilience @@ -354,6 +396,7 @@ Features: Available for: [![Node.js](/logos/nodejs.svg 'Link to the plugins repository.'){style="height:2.5em; display:inline; margin:0 0.2em;"}](https://github.com/cap-js/notifications#readme) +[![Java](/logos/java.svg 'Link to the plugins repository.'){style="height:3em; display:inline; margin:0 0.2em;"}](https://github.com/cap-java/cds-feature-notifications#readme) ## Telemetry