如何从Office加载项获取SharePoint O365文档ID

时间:2017-03-17 01:08:26

标签: sharepoint ms-office office-js

我在SharePoint Online中托管了自定义PowerPoint Office加载项。我使用JavaScript API获取有关套牌的信息,例如当前幻灯片ID。

Office.initialize = function (reason) {
  $(document).ready(function () {
    Office.context.document.addHandlerAsync('documentSelectionChanged', onDocumentSelectionChanged);
      onDocumentSelectionChanged();
    });
};

function onDocumentSelectionChanged() {
  Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange,
    function (result) {
      if (result.status === Office.AsyncResultStatus.Succeeded) {
        var slideId = result.value.slides[0].id;
      }
  });
}

我无法在API中找到任何内容来获取当前SharePoint文档的ID(guid)。这是Office API的一部分还是我可以通过其他方式获取ID?

1 个答案:

答案 0 :(得分:1)

你不能只从SourceDoc查询字符串属性中获取它吗?

您曾经能够将SourceDoc作为必需的令牌参数传递给插件。现在他们将它作为json字符串移动到window.name。因此,您需要执行JSON.parse(window.name).xdmInfo以及一些额外的字符串操作来清理URL。它包含sharepoint URL中的sharepoint url和文档的GUID