Use sendNotification API
You can use sendNotification API to send notifications to application users. Notifications can be accessed in the Notifications panel, and via email by configuration in the script.
With sendNotification API, you can trigger notifications when the analytic application is running at the backend, for example, when it’s scheduled for publication. You can also trigger at application runtime, for example, upon click of a button or initialization of the application.
If you want to send notifications without scheduling, ensure that your own mail server’s been configured. For more information, refer to Configure Custom SMTP Server.
Application.sendNotification({ title: string, content?: string, receivers?: string[], // default: current application user mode?: ApplicationMode, // default: Present parameters?: UrlParameter[], // array, no optional single URL parameter isSendEmail?: boolean, // default: false IsSendMobileNotification?: boolean // default: false });
Each notification includes a title and a button to open the analytic application.
-
content (in HTML format with limited support, including tags <i>, <b>, <u>, <a> and <br>)
-
recipients
-
application mode (Present, Embed or View)
-
URL parameters as key-value pairs
-
whether to send an email notification or not
-
whether to send the notification to SAP Analytics Cloud iOS mobile app or not
You can't send email notifications to non-SAP Analytics Cloud recipients.
In this example, when the application is opened, it will send notifications to Jack if <quantitySold> is below 50 million. He can receive notifications in both Notifications panel and email, and open the application in presentation mode. The notification title is Quantity sold below 50M, and content is The quantity sold is below estimation. For more details, please check it out in the analytic application.
Write the following script for the onInitialization event of canvas:
if (quantitySold < 50) { var notificationTitle = "Quantity sold below 50M"; var notificationContent = “The quantity sold is below estimation. For more details, please check it out in the analytic application”; Application.sendNotification({ title: notificationTitle, content: notificationContent, receivers: ["Jack"], mode: ApplicationMode.Present, isSendEmail: true }); }