Reputation: 43
I am developing an Outlook Add-in for multiple organizations. Each organization requires a different configuration for the Add-in.
I would like to have a function that checks if there are any values in RoamingSettings
, and if not read the settings from a file.
Can I run a setup function before a task pane is opened or a button is clicked?
Alternatively how about creating and accessing custom settings through Microsoft Graph for the organization in the add-in?
Upvotes: 1
Views: 80
Reputation: 33114
It isn't possible to execute code prior to the Add-in being launched. It also isn't possible to read from RoamingSettings
for several reasons; most notably because Add-ins are executed within a sandboxed browser environment may be running on a non-Windows machine (Mac, iOS, Android, Web)
Keep in mind that the Add-in isn't installed in their Outlook client, it is installed to their mailbox on the backend. They are also scoped to the mailbox item rather than the application. Without this it, add-ins wouldn't be able to operate across platforms (Outlook for Windows, Outlook for Mac, Outlook on the Web, etc.).
If you need to have configuration settings applied at the organization level and pushed out to any user, I would suggest storing them on your backend.
You can either use Exchange ID Tokens to identify the organization the user belongs too or request use the SSO functionality to fetch the tenant information from Microsoft Graph.
I've used Exchange ID Tokens for this in a number of add-ins. I generally use Azure Table Storage to store the settings (super inexpensive, very fast and easy to grab data via a couple of REST calls).
Upvotes: 1