OPEN TO WORK

Available for new opportunities! Let's build something amazing together.

#DevHack: Dismiss messaging extension dialog in MS Teams

API Development Microsoft Graph SharePoint
post

This post is over a year old, some of this information may be out of date.

Currently, I am developing my first “real” Microsoft Teams app with SharePoint Framework. In this app, I am making use of the new messaging extension capability.

{{< blockquote type="info" text="what are messaging extensions?

While developing a form in my extension, I wanted to cancel and submit a button. When I started implementing the cancel button, its onClick event, I was lost in how to close the dialog.

While going through the documentation, I found that you can do this by calling microsoftTeams.tasks.submitTask(). It was a bit hidden away on this page: task modules.

In your SharePoint Framework code, it looks as follows:

if (this.context.sdks.microsoftTeams) {
// Close the current dialog
this.context.sdks.microsoftTeams.teamsJs.tasks.submitTask();
}

Happy MS Teams development

Related articles

Report issues or make changes on GitHub

Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.

Comments

Elio Struyf

Solutions Architect & Developer Expert

Loading...

Let's build together

Manage content in VS Code

Present from VS Code