Search code examples
office365-appsoutlook-web-addins

Where to save user setting in an Office365 app


I am developing an app for Office365 (to be specific for Outlook) and I am having a question about where to keep the user settings.

This app is targeted for web version of Office365 as a result I hosted on a server. A user of Office365 can go to the store and install the app. However before s/he can use the app, s/he has to set a few fields to be able to use the add-on.

I am not sure if there is a way to keep the settings for a user.


Solution

  • You can use the RoamingSetting object API to save private data for your Addin for each user.

    // Get the current value of the 'myKey' setting
    var value = Office.context.roamingSettings.get('myKey');
    
    // Update the value of the 'myKey' setting
    Office.context.roamingSettings.set('myKey', 'Hello World!');
    
    // Persist the change
    Office.context.roamingSettings.saveAsync();
    

    For more information, look at the documentation link provided above.

    If you instead want to save data for your Addin for an email/calendar item (instead of for an entire mailbox), look at the CustomProperties object API.