Last active
November 19, 2018 15:05
-
-
Save JamesIgoe/45b597d5416b5fccb426ab14e33e4bce to your computer and use it in GitHub Desktop.
Settings manager providing add delete and update for Outlook mailbox settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var settingsManager = (function () { | |
"use strict"; | |
var settingsManager = {}; | |
var _settings; | |
settingsManager.initialize = function () { | |
//global for custom property | |
_settings = Office.context.roamingSettings; | |
settingsManager.checkPropertyValue = function checkPropertyValue (propertyToManage, value) { | |
var check = _settings.get(propertyToManage); | |
if (check === null || typeof check === 'undefined') { | |
this.setAddInSetting(propertyToManage, value); | |
check = value; | |
} | |
return check; | |
}; | |
// Set a roaming setting | |
settingsManager.setAddInSetting = function setAddInSetting (propertyToManage, value) { | |
_settings.set(propertyToManage, value); | |
_settings.saveAsync(saveAddInSettingsCallback); | |
}; | |
// Remove an add-in setting. | |
settingsManager.removeAddInSetting = function removeAddInSetting (propertyToManage) { | |
_settings.remove(propertyToManage); | |
_settings.saveAsync(saveAddInSettingsCallback); | |
}; | |
// Callback method after saving custom roaming settings. | |
function saveAddInSettingsCallback (asyncResult) { | |
if (asyncResult.status === Office.AsyncResultStatus.Failed) { | |
app.showNotification("Save Settings for" + propertyToManage, asyncResult.error.message); | |
} | |
} | |
}; | |
return settingsManager; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment