Back to column formats
Column formattingSharePoint Online

Custom Share to Teams

This sample demonstrates displaying a Share to Microsoft Teams screen with a message and URL.

screenshot of the sample
Sample preview · View original animation

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeTertiary--hover",
    "href": "='https://teams.microsoft.com/share?msgText='+ [$ShareMessage] +'\n' + '&href=' + [$URL] + '&s=' + Number(@now)",
    "target": "_blank"
  },
  "style": {
    "font-size": "10px",
    "fill": "currentColor",
    "width": "10em",
    "flex-direction": "row",
    "text-decoration": "none"
  },
  "children": [
    {
      "elmType": "svg",
      "attributes": {
        "viewBox": "0 0 1000 949.02"
      },
      "style": {
        "padding": ".5em",
        "width": "40%"
      },
      "children": [
        {
          "elmType": "path",
          "attributes": {
            "d": "m769.39,751.89c31.49,14.47,48.71,21.98,91.98,21.45,34.69-2.76,59.49-15.44,81.66-32.91,61.14-48.16,55.87-106.17,55.87-173.75,0-27.24,4.91-146.07-6.06-166.17-5.8-10.62-17.82-21.56-32.61-24.73-15.96-3.43-194.21-1.4-225.78-1.22l8.39,3.94c10.19,4.28,15.45,7.02,22.23,17.72,8.7,13.71,9.19,21.82,9.1,43.18-.37,85.42,1.7,184.08-.1,267.25-.89,16.65-3.63,31.47-4.68,45.25h0Z"
          },
          "style": {
            "fill": "#4b52bb"
          }
        },
        {
          "elmType": "path",
          "attributes": {
            "d": "m849.13,75.02c55.13,0,99.82,44.69,99.82,99.82s-44.69,99.82-99.82,99.82-99.82-44.69-99.82-99.82,44.69-99.82,99.82-99.82h0Z"
          },
          "style": {
            "fill": "#4b52bb"
          }
        },
        {
          "elmType": "path",
          "attributes": {
            "d": "m277.65,723.9c2.56,61.72,43.69,122.55,75.66,154.01,111.72,109.92,292.49,90.95,383.4-46.77,24.35-36.87,28.63-59.48,32.68-79.25,3.02-18.3,3.93-27.45,4.95-45.25,1.8-83.18-.39-181.84-.02-267.25.09-21.36-.16-29.86-8.86-43.57-8.31-13.1-16.45-16.11-31.01-21.26l-234.69-.05c0,95.66-.23,191.35,0,287.01-.44,51.48-19.08,62.39-79.87,62.39h-142.26Z"
          },
          "style": {
            "fill": "#7b82ea"
          }
        },
        {
          "elmType": "path",
          "attributes": {
            "d": "m524.71,0c82.72,0,149.77,67.06,149.77,149.77s-67.06,149.77-149.77,149.77c-8.27,0-16.38-.67-24.28-1.96-.1-5.79-.1-10.94-.2-22.31-.45-21.17-12.18-33.31-16.02-36.69-6.41-5.75-19.22-13.57-34.13-13.07-19.94,0-41.75-.1-54.66-.1-13.02-22.2-20.48-48.06-20.48-75.65C374.93,67.06,441.99,0,524.71,0h0Z"
          },
          "style": {
            "fill": "#7b82ea"
          }
        },
        {
          "elmType": "path",
          "attributes": {
            "d": "m50.06,225.28h400.47c27.53,0,50.06,22.53,50.06,50.06v400.47c0,27.53-22.53,50.06-50.06,50.06H50.06c-27.53,0-50.06-22.53-50.06-50.06v-400.47c0-27.53,22.53-50.06,50.06-50.06h0Zm97.42,121.78l.45,41.38h79.3v213.2h49.43v-212.76h75.56v-41.82h-204.74Z"
          },
          "style": {
            "fill": "#4b52bb"
          }
        }
      ]
    },
    {
      "elmType": "div",
      "style": {
        "font-size": "1em",
        "text-align": "center",
        "text-transform": "uppercase"
      },
      "txtContent": "Share to Teams"
    }
  ]
}
Schema compatibility review notes

This historical definition differs from the pinned Microsoft schema. This may indicate an unsupported pattern or a schema limitation. Check the original requirements and test in your tenant before use.

  • /children/0/attributes/viewBox must be object
  • /children/0/attributes/viewBox must match pattern "^(?:[\-+]?\d+\s*[\s,]\s*){3}(?:[\-+]?\d+)$"
  • /children/0/attributes/viewBox must match a schema in anyOf

From the contributor

How to use this sample

Summary

Sometimes you might need a more specialised "Share to Teams" option - this one allows for sharing a short synopsis & URL!

screenshot of the sample

View requirements

  • Sample is applied to a calculated column type (formula ="")
Column Name Type Notes
ShareMessage Text Limit to 200 characters
URL Multiple lines of text Link will only parse 1 parameter, any more will be assumed to be part of the request to Teams
  • Instead of the extra columns, you could hardcode the share url by replacing the [$ShareMessage] and [$URL] content in the attached format

Sample

Solution Author(s)
generic-share-to-teams-with-message.json Bianca W

Version history

Version Date Comments
1.0 October 15, 2023 Initial release

Additional notes

This solution was originally designed to be part of a bigger view, and has been re-designed for sharing with the community.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.