Use sendNotification API
You can use sendNotification API in analytic applications and optimized stories to send notifications to viewers. 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 or story is running at the backend, for example, when it’s scheduled for publication. You can also trigger in view time, for example, upon click of a button or initialization of the application or story.
If you want to send notifications without scheduling, ensure that your own mail server’s been configured. For more information, refer to Configure Email Server.
Application.sendNotification({ title: string, content?: string, receivers?: string[], // default: current 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 or story.
-
content (in HTML format with limited support, including tags <i>, <b>, <u>, <a> and <br>)
-
recipients
-
application or story 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 or story 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 or story 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..
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.”; Application.sendNotification({ title: notificationTitle, content: notificationContent, receivers: ["Jack"], mode: ApplicationMode.Present, isSendEmail: true }); }