如何在Outlook 2016桌面客户端上使用OfficeJS API的Dialog API [英] How to get working Dialog API of OfficeJS API with Outlook 2016 desktop client

查看:144
本文介绍了如何在Outlook 2016桌面客户端上使用OfficeJS API的Dialog API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个Outlook加载项,该加载项使用OfficeJS API并希望在应用程序内实现OAuth, API加密表示Outlook 2016(桌面)支持设置为1.1、1.2、1.3&的要求1.4,但就我而言,它保持沉默甚至不会引发错误. 运行工作时,单词插件的对话框api示例 JavaScript运行时错误: Unable to get property 'displayDialogAsync' of undefined or null reference.

I developed a outlook add-in which using OfficeJS API and want to implement OAuth within app, also API Documnetation says Outlook 2016(Desktop) supports requirements set 1.1, 1.2, 1.3 & 1.4 but in my case it remains silent not even throws an error. While running working dialog api sample for word add-in i am getting JavaScript run-time error: Unable to get property 'displayDialogAsync' of undefined or null reference.

我正在使用Microsoft Office Professional Plus 2016.

I am using Microsoft Office Professional Plus 2016.

我为启动对话框编写的代码如下:

Code I wrote to launch a dialog is below:

dialogTest() {
        const url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=....";
        Office.context.ui.displayDialogAsync(url, { width: 15, height: 27, requireHTTPS: true }, function (asyncResult) {
            if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
                // TODO: Handle error.
                return;
            }

            // Get the dialog and register event handlers.
            var dialog = asyncResult.value;
            dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, function (asyncResult) {
                if (asyncResult.type !== Microsoft.Office.WebExtension.EventType.DialogMessageReceived) {
                    // TODO: Handle unknown message.
                    return;
                }

                // Parse the message.
                var data = JSON.parse(asyncResult.message);
                console.log('Hello #Office365Dev', data.name);

                // TODO: Do something with the data.

                // We got our data, time to close the dialog.
                dialog.close();
            });
        });
    }

推荐答案

未定义Office.contextui成员,或者未正确加载Office.js.尝试首先查看以下内容:

Looks like ui member of Office.context is not defined or Office.js is not loaded correctly. Try to review these first:

  • Office.js javascript是否正确加载?
  • Office.initialize 回调是否已正确设置并执行在你做某事之前?
  • 您的Outlook Desktop 2016版本是什么?
  • Is Office.js javascript loaded correctly?
  • Does Office.initialize callback well set and executed before you do something?
  • What is your Outlook Desktop 2016 version?

编辑:2016年6月与Microsoft工程师进行了讨论(这不是官方声明). dialogAPI的受支持版本是Office for Windows Desktop 2016(版本16.0.6741.0000或更高版本).这可能会改变.

discussing with Microsoft engineer on June 2016 (this is no official statement). The supported builds for dialogAPI is Office for Windows Desktop 2016 (build 16.0.6741.0000 or above). This may change.

  • 这段代码的结果是什么 var result = Office.context.requirements.isSetSupported('DialogAPI', '1.4');
  • What is the result of this piece of code var result = Office.context.requirements.isSetSupported('DialogAPI', '1.4');

这篇关于如何在Outlook 2016桌面客户端上使用OfficeJS API的Dialog API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆