我的客户已决定迁移到Office 2016,并将业务流程的部分移植到该客户端,这要求我们提供替代文档信息面板,该面板不再可用。 Backstage文件信息区域对于有问题的用户来说不被视为足够的用户体验,因此我们正在努力用任务窗格应用程序替换DIP。(适用于Office的JavaScript API 1.3)设置自定义属性的值
这个例子:https://www.youtube.com/watch?v=LVGqpns0oT8&feature=share表明这个想法至少在理论上是可能的。我们考虑购买这个应用程序,但无法找到足够的信息来这样做。
所以我们着手尝试复制我们在DIP中需要的功能。看来,我们能够成功地设置文档属性的标准类型,如字符串,它看起来是这样的:
Word.context.run(function(context){
var properties = context.document.properties;
context.load(properties):
return context.sync().then(function(){
properties.title = properties.title + " Additional Title Text"; // once the sync goes off, this works.
return context.sync();
});
});
然而,当我们试图更新文档属性那是,例如,托管元数据属性定义通过SharePoint内容类型,代理对象中的值加载并保持更改,但似乎将其与实际文档属性的关系断开。下面的代码演示:
Word.context.run(function(context){
var properties = context.document.properties;
var customProperties = properties.customProperties;
context.load(properties):
context.load(customProperties);
return context.sync().then(function(){
var managedMetadataProperty = customProperties.getItem('MngdMetadata');
properties.title = properties.title + " Additional Title Text"; // once the sync goes off, this works.
context.load(managedMetadataProperty);
return context.sync().then(function(){
console.log(managedMetadataProperty.value) // let's say this looks like "10;#Label 1|64d2cd3d-57d4-4c23-9603-866d54ee74f1"
managedMetadataProperty.value = "11;#Label 2|cc3d57d4-4c23-72d4-3031-238b9100f52g"
return context.sync(); // now the value in the javascript object for managedMetadataProperty is updated, but the value in the document does not change.
});
});
});
文档属性托管元数据属性永远不会改变的话UI,也不会改变推回SharePoint。假设我们在更新后保存并关闭文档,然后重新打开它。 Property值没有明显改变,但是当我们用'context.load()'加载代理对象时,可用的值反映了我们在上次运行时所做的更改。
我不清楚为什么会这样。似乎要绕过这一点,我需要拨打电话回到SharePoint以更新相关字段,但我不知道如何指示Word使用SharePoint的新信息进行刷新。
这是伟大的知道。我会看一看。谢谢您的帮助。 –
但是,我会问,如何确定NameSpace或属性的ID? ContentType中定义的信息在文档的实例中是否相同? 再次感谢您的帮助。 –
你去得到这个命名空间http://schemas.microsoft.com/office/2006/metadata/properties –