Office加载项Office.context.ui.displayDialogAsync窗口在激活“发送时”功能时不会出现

时间:2019-10-09 19:20:55

标签: office-js outlook-web-addins

我正在尝试将Office对话框窗口添加到"No Send" tutorial。我可以完美地运行本教程,被阻止的单词也可以按预期被阻止。但是,当我尝试修改教程以添加displayDialogAsync()时,对话框代码将被完全忽略,并且我根本看不到弹出窗口。这是我的修改,其中displayInIFrame设置为false:

function validateBody(asyncResult) {

        Office.context.mailbox.item.notificationMessages.addAsync('NoSend', { type: 'errorMessage', message: 'Processing mail about to be sent.' });
            var dialog

            var url = "https://localhost:3000/test.html"
            Office.context.ui.displayDialogAsync(url, { width: 80, height: 60, displayInIframe: true }, function(result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                        console.log("FAILED: " + result.error.message)
                        reject(new DialogError(result.error.message, result.error))
                }
                 dialog = result.value
          dialog.addEventHandler(Office.EventType.DialogMessageReceived, args => {
                                    console.log("MSG RECVD")
                                    console.log(args.status)
                                    if(true){ // just for testing; both branches cause the Send button to grey out
                                            asyncResult.asyncContext.completed({ allowEvent: true });
                                    }
                                    else {
                                            asyncResult.asyncContext.completed({ allowEvent: false });
                                    }
                            })
                    dialog.close()

            })


   //asyncResult.asyncContext.completed({ allowEvent: true });
        }

如果将displayInFrame更改为true,则放入函数中,然后看到错误:

  

操作失败,因为此加载项已经具有一个活动对话框。

我已验证我的测试HTML存在并且可以被浏览器访问。我还检查了this question

0 个答案:

没有答案