简体   繁体   中英

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.

As you can see I'm using the latest stable version of 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:

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). Because I've downloaded the file, the UUIDs and valid domains are perfect matches.

{
  "$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. WRONG . You must register a save handler.

The documentation does not state that setSettings is required. WRONG . You must set settings or else you will receive this error.

The documentation does not state that you must save a contentURL . WRONG . You must set content URL in the setSettings . You can apparently omit other things when setting your settings, but not content URL.

The documentation does not specifically mention it, but the contentURL must comply with your validURLs in your manifest. If it does not, you'll also see this error.

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