I am using the Settings
Object of the JavaScript API in a Task Pane App to save some key-value pairs in the document.
My code is something like this
Office.context.document.settings.set(key, value);
Office.context.document.settings.saveAsync(function () {
Toast.showToast("Setting saved", "Info saved into the document using saveAsync");
});
I am also calling the saveAsync
function on it to persist the value.
The problem I am facing is that settings are not being persisted in Word Online as currently settings Object is not supported in Word Online
So is there a way to find that the application is Running in Word Online, so a message could be displayed, or localStorage or something else can be used to save values.
Edit: Created a uservoice request to add this in Word Online, you can support this feature here
Edit 2
To better explain the problem and share an example, I have created a sample addon, the manifest is located here.
Here you can type the value for the key test
and press save, this internally calls the function saveToPropertyBag(key, value)
located in StorageLibrary.js
. This function has the above mentioned code to save the setting and then saveAsync
is called so the values get persisted in the document.
Now you can refresh the browser or reload the addon, and press get, the value will be available in Excel and Powerpoint but not in Word Online.
So I am looking a way to detect the host(Word Online) so that I can fall back to alternate way to store the value like local Storage and also display a warning to user.