简体   繁体   中英

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. In Office Outlook Online everything works fine, but on Office Outlook Desktop the command is not being executed. Why is that so?

The addin is hosted on a node.js server based on Ubuntu 14.04 with a valid certificate for 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. 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. 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. 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.

That the command is not being executed on Outlook Desktop when hosting my addin on a ubuntu based nodejs server is my problem. 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 ")

<?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. 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. You can also try calling the notificationMessages API to see a visible effect in the message.

This doc describes how to implement the function defined by FunctionName in the manifest. For asynchronous code, event.completed() should actually be called within the callback.

Debugging a UI-less add-in is tricky because the F12 Debugger will only attach once the add-in is running. You can use Fiddler to verify that the .html is loading successfully (this can help rule-out a certificate error). 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).

Quite sure the problem is as follows (at least in word desktop).

1) the commands and taskpane work on different javascript contexts. Ie A function running in the command pane cannot access the taskpane.

2) the command ribbon is memoryless. They launch a new headless js context everytime you click a button.

3) since it's headless, it can't open new window.

4) since the ribbon is disconnected from the taskpane, any window.location change attempts don't redirect the task pane.

I "worked around" this by having a websocket to bounce commands off the server. Yes. Seriously.

Incidentally that Websocket is how i verified the button is indeed working. 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.

Please bonk whoever "designed" this on the head for me with a giant inflatable hammer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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