【问题标题】:Why does my Office Addin command without UI not respond while the same command send from taskpane does?为什么没有 UI 的 Office Addin 命令没有响应,而从任务窗格发送的相同命令却有响应?
【发布时间】:2019-06-06 09:15:25
【问题描述】:

我有一个 Outlook 插件,可以在按下命令按钮时重定向到外部网站。在 Office Outlook Online 中一切正常,但在 Office Outlook 桌面上,该命令未执行。为什么会这样?

插件托管在基于 Ubuntu 14.04 的 node.js 服务器上,并具有有效的 https 证书。如果我使用按钮从任务窗格调用相同的命令,则会执行该命令并重定向用户。

我在设置服务器时遇到了很多问题,但现在服务器正在运行并且可以毫无问题地访问文件。 我认为这可能是我的自签名证书有问题,并将其更改为来自受信任来源的证书,但输出是相同的。 但是,在本地运行它,就像从我的 Windows 系统启动本地 node.js 服务器并通过 localhost 调用它一样。正在执行命令。

我希望 Outlook 桌面中命令按钮的命令的执行方式类似于它在 Outlook Web 中的执行方式。 它不显示任何错误消息。 notificationMessage 只是一直告诉我它当前正在执行命令,但什么都没有发生,甚至没有改变。 我必须通过关闭窗口来强制任务停止。

我看到其他人提到了类似的问题 (How to get 'Commands' button working in Office Addins?),但它的答案对我的问题没有帮助。

在基于 ubuntu 的 nodejs 服务器上托管我的插件时,该命令未在 Outlook 桌面上执行是我的问题。 如果有人知道如何解决这个问题或者看到有人遇到同样的问题,我会非常感激,这可以解决它。

谢谢。

清单.xml (出于保密原因,真实的服务器名称被交换为“ourServer”bc。) GotoSite -> window.open("https://google.com")

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
  <Id>0ec8dc72-014b-4426-acd3-f06edeb15052</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Convien</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Convien"/>
  <Description DefaultValue="Come together... right now!"/>
  <IconUrl DefaultValue="https://ourServer.convien.com:3000/assets/Convien32X32.png"/>
  <HighResolutionIconUrl DefaultValue="https://ourServer.convien.com:3000/assets/Convien80X80.png"/>
  <SupportUrl DefaultValue="https://convien.com"/>
  <AppDomains>
    <AppDomain>convien.com</AppDomain>
    <AppDomain>https://easy.convien.com</AppDomain>
    <AppDomain>https://www.google.com</AppDomain>
    <AppDomain>https://stress.convien.com/convien_outlook/</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Mailbox"/>
  </Hosts>
  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1"/>
    </Sets>
  </Requirements>
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://ourServer.convien.com:3000/src/taskpane/taskpane.html"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>
  <Permissions>ReadWriteItem</Permissions>
  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit"/>
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
        <bt:Set Name="Mailbox"/>
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <FunctionFile resid="Commands.Url"/>
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="msgReadGroup">
                <Label resid="GroupLabel"/>                
                <Control xsi:type="Button" id="linkButton">
                  <Label resid="LinkButton.Label"/>
                  <Supertip>
                    <Title resid="LinkButton.Label"/>
                    <Description resid="LinkButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.80x80"/>
                    <bt:Image size="32" resid="Icon.80x80"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ExecuteFunction">
                    <FunctionName>GotoSite</FunctionName>
                  </Action>
                </Control>
              </Group>

            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://ourServer.convien.com:3000/assets/Convien80X80.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://ourServer.convien.com:3000/assets/Convien80X80.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://ourServer.convien.com:3000/assets/Convien80X80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Commands.Url" DefaultValue="https://ourServer.convien.com:3000/src/commands/commands.html"/>
        <bt:Url id="Taskpane.Url" DefaultValue="https://ourServer.convien.com:3000/src/taskpane/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="GroupLabel" DefaultValue="Meeting Place"/>
        <bt:String id="LinkButton.Label" DefaultValue="Convien Easy"/>

      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="LinkButton.Tooltip" DefaultValue="Opens Convien Easy web application."/>        
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

【问题讨论】:

  • 你能分享你的清单吗?
  • 当然。我更新了问题。
  • 当你说它在 Office Online 中工作时 - 你使用的是什么浏览器?尝试 IE 并在 Dev Tools (F12) 中查看控制台,IE 经常需要 polyfill,Office Desktop Addins 是 IE 包装器
  • @LeonardoSeccia 感谢您提供有关 IE 的提示。它有助于使用 IE 进行调试,因为我一直在使用 Firefox。

标签: javascript node.js outlook office-js outlook-web-addins


【解决方案1】:

有两种可能性:函数没有成功执行,或者特定的“重定向”代码正在运行但没有达到预期的效果。由于您提到代码是在任务窗格中运行的,因此此答案将涵盖第一种可能性。

'in-progress' 通知消息表明 event.completed() 在执行函数结束时没有被调用。第一步是验证 event.completed() 是否已定义,然后单步执行代码以确保函数成功运行。您也可以尝试调用notificationMessages API 来查看消息中的可见效果。

This doc 描述了如何实现清单中 FunctionName 定义的函数。对于异步代码,实际上应该在回调中调用 event.completed()。

调试无 UI 插件很棘手,因为 F12 Debugger 只会在插件运行后附加。您可以使用 Fiddler 来验证 .html 是否已成功加载(这有助于排除证书错误)。如果需要,您可以附加 Visual Studio 脚本调试器,它应该在加载项执行之间保持附加(为此,调用 event.completed() 很重要,因为否则第二次执行将排队,等待第一次执行完成)。

【讨论】:

    【解决方案2】:

    很确定问题如下(至少在word桌面中)。

    1) 命令和任务窗格适用于不同的 javascript 上下文。 IE。在命令窗格中运行的函数无法访问任务窗格。

    2) 命令功能区是无记忆的。每次您单击按钮时,它们都会启动一个新的无头 js 上下文。

    3) 由于它是无头的,因此无法打开新窗口。

    4) 由于功能区已与任务窗格断开连接,因此任何 window.location 更改尝试都不会重定向任务窗格。

    我通过使用 websocket 从服务器反弹命令来“解决”这个问题。是的。严重地。

    顺便说一句,Websocket 是我验证按钮确实工作的方式。即使我对重定向的工作方式有误,这也是一个非常有用的调试工具,因为 f12 调试器无法附加到命令功能区。

    请用巨大的充气锤敲打“设计”这个东西的人的脑袋。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      • 2018-10-04
      • 2017-03-20
      相关资源
      最近更新 更多