Document custom properties not save in Office 365 for Windows

瘦欲@ 提交于 2019-12-11 15:45:20

问题


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.


回答1:


Thanks for reporting this issue. I actually tried to repro it on the cited build but I am not able to. There is actually a bug we have right now (knwon issue) that when you save custom doc properties and save the document, the document keeps a dirty state, meaning the user will be prompted to save the document again (even if after creating the properties and saving the doc using the UI).

there is no data loss though, just a pop of a "Want to save changes?" dialog that really does not make sense given the doc was explicitly saved but what i observed is that the even if the user selects to not save on that dialog, the properties are still persisted.



来源:https://stackoverflow.com/questions/52062904/document-custom-properties-not-save-in-office-365-for-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!