简体   繁体   English

saveEvent 上的 notifySuccess 不起作用,在控制台中看到错误

[英]notifySuccess on saveEvent not working, seeing error in console

I'm trying to build a screen to save a connector and I cannot get the Save button to work.我正在尝试构建一个屏幕来保存连接器,但我无法使“保存”按钮起作用。 It throws a JavaScript error from deep inside Teams itself.它从 Teams 内部深处引发 JavaScript 错误。

As you can see I'm using the latest stable version of Teams JS.如您所见,我使用的是最新的稳定版 Teams JS。

My code has been boiled down to as simple as can be made.我的代码已被归结为尽可能简单。 It just inits and sets the Save button validity so it can be clicked.它只是初始化并设置“保存”按钮的有效性,以便可以单击它。

<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://res.cdn.office.net/teams-js/2.7.1/js/MicrosoftTeams.min.js" crossorigin="anonymous">
    </script>
  </head>
  <body>
    <p>Testing 6</p>

    <script>
      async function init() {
        await microsoftTeams.app.initialize();
        microsoftTeams.pages.config.setValidityState(true);
      }

      init();
    </script>
  </body>
</html>

If I load up the console in my web browser, this is the error I receive:如果我在我的 web 浏览器中加载控制台,这是我收到的错误:

2023-01-25T03:00:00.927Z Received error from connectors {
  "seq":1674609016862,
  "timestamp":1674613638241,
  "flightSettings":{
    "Name":"ConnectorFrontEndSettings",
    "AriaSDKToken":"d12...",
    "SPAEnabled":true,
    "ClassificationFilterEnabled":true,
    "ClientRoutingEnabled":true,
    "EnableYammerGroupOption":true,
    "EnableFadeMessage":false,
    "EnableDomainBasedOwaConnectorList":false,
    "EnableDomainBasedTeamsConnectorList":false,
    "DevPortalSPAEnabled":true,
    "ShowHomeNavigationButtonOnConfigurationPage":false,
    "DisableConnectToO365InlineDeleteFeedbackPage":true,
    "RemoveAnchorHeader":true
  },
  "status":500,
  "clientType":"SkypeSpaces",
  "connectorType":"92a...",
  "name":"handleMessageError"
}

The manifest file is also simple: it is the one downloaded from the Connector Dashboard (with the invalid part deleted and the schema version upgraded because the dashboard generates INVALID MANIFESTS). manifest文件也很简单:就是从Connector Dashboard下载的(删除无效部分,升级schema版本,因为dashboard生成INVALID MANIFESTS)。 Because I've downloaded the file, the UUIDs and valid domains are perfect matches.因为我已经下载了文件,所以 UUID 和有效域是完美匹配的。

{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.15/MicrosoftTeams.schema.json",
  "manifestVersion": "1.15",
  "id": "2ac21268...",
  "version": "1.0.0",
  "packageName": "com.Simple I/O (Development 3)",
  "developer": {
    "name": "Developer",
    "websiteUrl": "https://3821-68-69-235-13.ngrok.io",
    "privacyUrl": "https://3821-68-69-235-13.ngrok.io",
    "termsOfUseUrl": "https://3821-68-69-235-13.ngrok.io"
  },
  "description": {
    "full": "Simple I/O (Development 3)",
    "short": "Simple I/O (Development 3)"
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "connectors": [
    {
      "connectorId": "2ac21268...",
      "scopes": [
        "team"
      ],
      "configurationUrl": "https://3821-68-69-235-13.ngrok.io/teams/connector"
    }
  ],
  "name": {
    "full": "Simple I/O (Development 3)",
    "short": "Simple I/O (Development 3)"
  },
  "accentColor": "#FFFFFF",
  "validDomains": [
    "3821-68-69-235-13.ngrok.io"
  ]
}

Despite everything mentioned in the documentation , the following is required otherwise you'll get this error.尽管文档中提到了所有内容,但以下内容是必需的,否则您将收到此错误。 This fixed things for me.这为我解决了问题。

microsoftTeams.settings.registerOnSaveHandler(saveEvent => {
  microsoftTeams.settings.setSettings({
    contentUrl: "https://xxxxxx.ngrok.io/teams/connector"
  });

  saveEvent.notifySuccess();
});

The documentation states that registering a save handler is optional and Teams will handle notify success if it's not declared.文档指出注册保存处理程序是可选的,如果未声明,Teams 将处理通知成功。 WRONG .错了 You must register a save handler.您必须注册一个保存处理程序。

The documentation does not state that setSettings is required.该文档没有 state setSettings是必需的。 WRONG .错了 You must set settings or else you will receive this error.您必须设置设置,否则您将收到此错误。

The documentation does not state that you must save a contentURL .该文档没有 state 您必须保存一个contentURL WRONG .错了 You must set content URL in the setSettings .您必须在 setSettings 中设置内容setSettings You can apparently omit other things when setting your settings, but not content URL.您显然可以在设置设置时省略其他内容,但不包括内容 URL。

The documentation does not specifically mention it, but the contentURL must comply with your validURLs in your manifest.文档没有具体提及,但contentURL必须符合清单中的validURLs If it does not, you'll also see this error.如果没有,您也会看到此错误。

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

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