Outlook加载项:按下“操作”时调用“任务窗格”的js代码

时间:2020-07-28 14:46:48

标签: outlook-web-addins

我有一个带有2个选项的Outlook插件:1个按钮用于“操作” + 1个按钮用于“任务窗格”。 我正在Office 365网站中测试我的插件。

“任务窗格” 代码(与任务窗格关联的.js文件)中,我有以下代码:

Office.onReady(info => {
    if (info.host === Office.HostType.Outlook) {
        console.log("Hello from pane");
...

当我单击加载项中的“操作” 时,此代码也被称为(打印“来自窗格的Hello”)

可以吗?如果是这样,我怎么知道按下了“任务窗格”选项,而不是按下了“动作”?

我的XML清单中的信息:

     <!-- New Appointment -->
      <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
        <!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
        <OfficeTab id="TabDefault">
          <!-- Up to 6 Groups added per Tab -->
          <Group id="Group">
            <Label resid="Group.Label" />
            <!-- Launch the add-in : action button -->
            <Control xsi:type="Button" id="ButtonAction">
              <Label resid="Action.Label" />
              <Supertip>
                <Title resid="Action.Supertip.Title" />
                <Description resid="Action.Supertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="icon16" />
                <bt:Image size="32" resid="icon32" />
                <bt:Image size="80" resid="icon80" />
              </Icon>
              <Action xsi:type="ExecuteFunction">
                <FunctionName>myAction</FunctionName>
              </Action>
            </Control>
             <!-- Launch the add-in : task pane button -->
            <Control xsi:type="Button" id="ButtonOpenPane">
              <Label resid="OpenPane.Label" />
              <Supertip>
                <Title resid="OpenPane.Supertip.Title" />
                <Description resid="OpenPane.Supertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="icon16" />
                <bt:Image size="32" resid="icon32" />
                <bt:Image size="80" resid="icon80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                <SourceLocation resid="OpenPane.Action.location" />
              </Action>
            </Control>
            <!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
          </Group>
        </OfficeTab>
      </ExtensionPoint>
      
 ...
  
  <bt:Urls>
    <bt:Url id="functionFile" DefaultValue="...FunctionFile.html"/>
    <bt:Url id="OpenPane.Action.location" DefaultValue="...taskpane.html"/>
  </bt:Urls>

预先感谢, 迭戈

1 个答案:

答案 0 :(得分:0)

除非您从功能文件HTML和任务窗格HTML中都引用了此.JS代码,否则不会出现这种情况。