Issue with Office.context.document.settings.get

后端 未结 1 1271
情书的邮戳
情书的邮戳 2021-01-17 02:37

I\'m reading settings from a Word Document using:

function callbackFunction(){
    var varValue = Office.context.document.settings.get(\"VariableName\");
}
<         


        
1条回答
  •  醉梦人生
    2021-01-17 03:24

    This issue is a symptom of side-loading add-ins. A little background on this might help.

    Certain add-in functionality, such as Settings, is keyed to a specific add-in. This allows you to ensure your settings don't get overwritten by another add-in that just happened to use the same setting name. When you retrieve your settings from Office, it is returning only those settings originally attributed to your add-in. This attribution is keyed off the add-in's ID from your manifest.

    When an add-in is loaded from the Store or your tenant's add-in catalog, the add-in assigns the id for that add-in from your manifest file. Since this value doesn't change, it allows you to maintain settings across platforms and versions of your add-in.

    Side-loading works differently. When you side-load an add-in, Office will assign it a randomly generated ID. This is done to ensure your development and production versions can co-exist side-by-side on the same machine. If Office used the ID from the manifest, it would effectively remove the production version of your add-in.

    In most cases, the effects of side-loading will have no effect on your add-in. That is unless you're attempting to test Settings across machines/platforms where the automatically generated ID breaks the connection between your add-in and it's settings.

    The workaround for this is to use a developer tenant and centrally publish your add-in there. This will automatically handle deployment of your add-in across each platform and ensure they all use the same ID value.

    0 讨论(0)
提交回复
热议问题