Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
enric101
Active Contributor
In many cases, a basic requirement of our applications is to be able to notify the user of any update in the system centrally.

We only had several options in the past to show tasks to the user: KPIs in a dynamic tile, customized plugin or receiving feedback after talking with a bot via SAP conversacional AI.

With the notification service in the SAP BTP launchpad, we can now give feedback to the user and allow them to take quick actions.

We will see how to configure our launchpad, add a type of notification and finally generate a notification via request. With these steps we can integrate e.g. other applications outside SAP, the SAP integration Suite or any other backend that uses Http protocol...

Initial configuration


Generating the notification service in SAP BPT


The first thing to do is to access the launchpad configuration page to generate and activate the notification service in lauchpad.


On the notifications page you will see the option to generate the service, so as you can imagine, we are going to click on the "generate" button.


Once the service has been generated, details will appear on the notifications page:



Showing notifications


The next step is to enable the notifications option in the launchpad settings.


In the configuration page we will activate the option to show notifications to the user:



Getting permission to make the notification


The first thing to do before performing any operation is to obtain the two tokens that we will use to send data. The first is the Bearer token, which gives us the authorisation to use the API and a second token called x-csrf-token which we will use to make POST requests.

Obtaining the Bearer token


To obtain the data we will use the url that shows us the launchpad configuration:


We will add this parameter to the URL at the end to indicate that we will use the client credentials mechanism.
?grant_type=client_credentials

Next will be the credentials, which we will also have in the launchpad configuration.


With this data we can now generate the token. This is the example of the data we would use in postman:


And this is a little trick to read the answer and add it in an environment variable.



Obtaining x-csrf-token


This token is used to make POST, so for get operations it is not necessary, and that is why we will make a GET request to obtain it.

In this case we will use the following URL: https://notifications.cfapps.eu10.hana.ondemand.com/v2/Notification.svc/Notifications

As authorization we will add the bearer token obtained in the previous call. We can add the variable.


We will add the token request: x-csrf-token = fetch


Although the response returns an error, the interesting thing is to extract the token from the response headers:


This token will have to be requested when making a Post.

Sending notifications


To continue with the example, we will create a notification type to alert users that a new application is available on their launchpad.

Creating a notification type


Now we will create a fairly simple notification, i.e. with a message without variable data.

We will use the following URL: https://notifications.cfapps.eu10.hana.ondemand.com/v2/NotificationType.svc/NotificationTypes and add the bearer and x-csrf-token obtained in the previous step:


And this will be the body that we will pass to it.

Where we generate an ID, a version and the text of the push notification.

The ones we will see in the launchpad when we click on the bell are TemplateSensitive and Subtitle, if we access by type, we will see templategrouped and as popup text we will see the value of public template.
{
"NotificationTypeKey": "NewApp",
"NotificationTypeVersion": "0.1",
"Templates": [
{
"Language": "en",
"TemplatePublic": "New application is ready",
"TemplateSensitive": "New application!",
"TemplateGrouped": "The new application is ready",
"TemplateLanguage": "Applications",
"Subtitle": "Application notification"
}
]
}

Now we are all set. Let's send a notification.

Sending a notification


To send notifications we will need to add the bearer token and the x-csrf-token as in the previous case.

To send the notification we will use this URL: https://notifications.cfapps.eu10.hana.ondemand.com/v2/Notification.svc/Notifications and this is the body that we will send:
{
"OriginId": "test",
"NotificationTypeKey": "NewApp",
"NotificationTypeVersion": "0.1",
"Priority": "Low",
"Recipients": [
{
"RecipientId": "ecastella@ecastella.com"
}
]
}

As we can see, we must add the email of the users we want to notify, for me this is a bug because as in the workflows topic, the field should be able to accept mails or groups.

Finally this is the result:


And here are some references to connect the service to a S4Hana system and to integrate with a ui5 application in an easy way.:

https://blogs.sap.com/2021/09/02/building-a-central-launchpad-using-sap-launchpad-service-enabling-n...

https://blogs.sap.com/2021/07/06/sending-notifications-from-sap-btp-applications-to-the-sap-fiori-la...

In conclusion, with this service you can add push notifications in the lauchpad + SAP Mobile Services Client. It's important to provide this type of services for your user because we can redirect the user's focus to their day-to-day tasks, and allow them to complete it with a few clicks.

Remember that the priority of any improvement is our users 😉

Please check or rise your question on this blog or in the following tag in the Q&A section: https://answers.sap.com/tags/538710751289542466232554247536294
6 Comments
Labels in this area