2

I'm trying to display a custom message, but window.alert() is restricted in OfficeJS.

I have found a solution which suggests using app.showNotification(title, message);

Office.initialize = function (reason) {
        $(document).ready(function () {
             app.showNotification("Title For the Notification", "test");
    });
 });

Browser throws

"app is undefined error".

Which module am I missing ?

Damian
  • 75
  • 1
  • 9
  • You grab 3 lines of code from context of [Office Add-in Dialog API Example](https://github.com/OfficeDev/Office-Add-in-Dialog-API-Simple-Example/tree/master/SimpleDialogSampleWeb) which uses `FabricUI` package to display alert style dialog (basically layer on the current page). Bottom line: `app` is the application someone defined in the code you didn't copy; `showNotification` is custom defined function someone implemented. Nothing to do with OfficeJS. – Slava Ivanov Jan 15 '19 at 14:34
  • I see, thank you for pointing that out. It's clear for me now! – Damian Jan 15 '19 at 18:39

2 Answers2

0

To answer on original question (in your title) you may use Fabric-UI Dialog API to achive this functionality. The examples of the options for available dialog's styles over here. You may use any other UI package as well ... JQuery UI, JQuery Mobile, etc.

Slava Ivanov
  • 6,666
  • 2
  • 23
  • 34
0

In addition to using the Fabric dialog as Slava suggested, you can also use the Dialog API in Office.js. There's a discussion of it here: Use the Dialog API in your Office Add-ins.

Rick Kirkham
  • 9,038
  • 1
  • 14
  • 32
  • I forgot to mention that I am currently using the Dialog API which I totally dislike because it does generate errors on Outlook Windows. I wanted to avoid it at all cost. – Damian Jan 15 '19 at 18:38