My office js Word add-in code saves a custom property to the document customproperty collection. The code for saving is as below
Word.run(function (context) {
//method accepts property name plus value
context.document.properties.customProperties.add(propertyname, value);
return context.sync()
.then(function () {
console.log("Property saved");
})
.catch (function (e) {
console.log("Error occured inserting property " + e.message);
});
});
When I create the document using Office 365 for Windows (Word desktop) and invoke my addin the properties are not getting saved into the custom properties collection. However the properties get saved when the document is created using Office Online. I amended the code to include a document.save but it makes no difference. Is there any limitation with this requirement set in Office 365 for Windows. Im on version Version 1803 (Build 9126.2275 Click-to-Run).
In Office 365 for Windows I can even see the custom property when I click on Info->Properties->AdvancedProperties->Custom. However for some odd reason the custom properties are not getting persisted in the document and when I reopen the document they are missing. This looks like a bug with the API in Office 365 for Windows. When we add a custom property to the collection via code it is not getting saved into the document. Even if we include a document.save before the context call, the custom property is not getting saved into the document property collection via code. So I inserted the custom property into the document via code and then hit the save button on Word menu. However this also did not save the custom property into the document. The only way that I can get the custom property to save into the document is by inserting some text into the document and hitting the save button on the menu.