简体   繁体   English

为什么没有UI的Office Addin命令在从taskpane发送相同命令时没有响应?

[英]Why does my Office Addin command without UI not respond while the same command send from taskpane does?

I have an outlook addin that redirects at press of the command button to an external website. 我有一个outlook addin,按下命令按钮重定向到外部网站。 In Office Outlook Online everything works fine, but on Office Outlook Desktop the command is not being executed. 在Office Outlook Online中,一切正常,但在Office Outlook桌面上,该命令未执行。 Why is that so? 为什么会这样?

The addin is hosted on a node.js server based on Ubuntu 14.04 with a valid certificate for https. 插件托管在node.js服务器上,该服务器基于Ubuntu 14.04,具有https的有效证书。 If I call the same command from the taskpane using a button, the command is executed and the user is redirected. 如果我使用按钮从任务窗格调用相同的命令,则执行该命令并重定向用户。

I had a lot of problem setting up the server, but now the server is running and the files are reachable without a problem. 我在设置服务器时遇到了很多问题,但现在服务器正在运行,文件可以无问题地访问。 I thought it may be a problem with my self-signed certificate and changed this to a certificate from a trusted source, but the output is the same. 我认为这可能是我的自签名证书的问题,并将其更改为来自可信来源的证书,但输出是相同的。 However running it locally as in starting a local node.js server from my windows system and calling it via localhost works. 但是在本地运行它就像从我的Windows系统启动本地node.js服务器并通过localhost调用它一样。 The command is being executed. 该命令正在执行中。

I expect the command of the command-button in Outlook Desktop to be executed similar to how its executed in Outlook web. 我希望Outlook桌面中命令按钮的命令执行类似于它在Outlook Web中执行的命令。 It does not show any error message. 它不显示任何错误消息。 The notificationMessage just keeps telling me that its executing the command currently, yet nothing happens or even changes. notificationMessage只是告诉我它当前正在执行命令,但没有任何反应甚至发生变化。 I have to force the task to stop via closing the window. 我必须通过关闭窗口强制停止任务。

I've seen someone else mention a similar problem ( How to get 'Commands' button working in Office Addins? ) but the answer of it does not help my problem. 我见过其他人提到类似的问题( 如何在Office Addins中使用'命令'按钮? )但它的答案对我的问题没有帮助。

That the command is not being executed on Outlook Desktop when hosting my addin on a ubuntu based nodejs server is my problem. 在基于ubuntu的nodejs服务器上托管我的插件时,在Outlook桌面上没有执行该命令是我的问题。 And I'd really appreciate if someone has an idea how to solve this or has seen someone having the same problem, that could resolve it. 我真的很感激,如果有人知道如何解决这个问题,或者看到有人遇到同样的问题,可以解决它。

Thank you. 谢谢。

Manifest.xml (The real servername is exchanged for the "ourServer" bc of confidential reasons.) GotoSite -> window.open(" https://google.com ") Manifest.xml(真正的服务器名称由于保密原因而被交换为“ourServer”。)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>

There are two possibilities: either the function is not executing successfully, or the specific "redirect" code is running but is not having the intended effect. 有两种可能:函数未成功执行,或者特定的“重定向”代码正在运行但没有达到预期的效果。 Since you mentioned that the code is working from a task pane, this answer will cover the first possibility. 既然您提到代码正在从任务窗格中运行,那么这个答案将涵盖第一种可能性。

The 'in-progress' notification message is an indication that event.completed() is not called at the end of the executed function. “进行中”通知消息表示在执行的函数结束时未调用event.completed()。 The first step is to verify that event.completed() is defined, and then to step through the code to ensure that the function is running successfully. 第一步是验证是否定义了event.completed(),然后逐步执行代码以确保函数成功运行。 You can also try calling the notificationMessages API to see a visible effect in the message. 您还可以尝试调用notificationMessages API以查看消息中的可见效果。

This doc describes how to implement the function defined by FunctionName in the manifest. 本文档描述了如何在清单中实现FunctionName定义的函数。 For asynchronous code, event.completed() should actually be called within the callback. 对于异步代码,应该在回调中实际调用event.completed()。

Debugging a UI-less add-in is tricky because the F12 Debugger will only attach once the add-in is running. 调试无UI的加载项很棘手,因为F12调试器只会在加载项运行后附加。 You can use Fiddler to verify that the .html is loading successfully (this can help rule-out a certificate error). 您可以使用Fiddler来验证.html是否正在成功加载(这可以帮助排除证书错误)。 And if needed, you can attach the Visual Studio script debugger, which should stay attached in-between add-in executions (for this, it's important that event.completed() is called because otherwise the second execution will be queued, waiting for the first execution to complete). 如果需要,您可以附加Visual Studio脚本调试器,它应该保持连接在插件执行之间(为此,调用event.completed()非常重要,否则第二次执行将排队,等待第一次执行完成)。

Quite sure the problem is as follows (at least in word desktop). 确定问题如下(至少在word桌面中)。

1) the commands and taskpane work on different javascript contexts. 1)命令和任务窗格适用于不同的javascript上下文。 Ie A function running in the command pane cannot access the taskpane. 即命令窗格中运行的功能无法访问任务窗格。

2) the command ribbon is memoryless. 2)命令功能区无记忆。 They launch a new headless js context everytime you click a button. 每次单击按钮时,它们都会启动一个新的无头js上下文。

3) since it's headless, it can't open new window. 3)因为它无头,所以无法打开新窗口。

4) since the ribbon is disconnected from the taskpane, any window.location change attempts don't redirect the task pane. 4)由于功能区与任务窗格断开连接,因此任何window.location更改尝试都不会重定向任务窗格。

I "worked around" this by having a websocket to bounce commands off the server. 我通过使用websocket从服务器上弹出命令来“解决”这个问题。 Yes. 是。 Seriously. 认真。

Incidentally that Websocket is how i verified the button is indeed working. 顺便说一句,Websocket是我验证按钮确实工作的方式。 Even if I'm wrong about how your redirect works, this is a stupidly useful debugging tool since the f12 debugger can't be attached to command ribbon. 即使我对重定向的工作方式有误,这也是一个非常有用的调试工具,因为f12调试器无法附加到命令功能区。

Please bonk whoever "designed" this on the head for me with a giant inflatable hammer. 请使用巨型充气锤为我“设计”这个头部的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM