Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript:navigator.registerProtocolHandler

Marclem

Technical User
Aug 5, 2003
96
US
Greetings,

I am trying to auto-populate an email content to auto create an email. I am using Microsoft Lists (I am not a programmer). My employer only allows outlook office 365 to be used over the web so we are not using the local outlook which it if we were I was able to find a code to auto create an email using the outlook local install.

Below is the Json code which calls for the javascript:navigator.registerProtocolHandler to register it on the web browser then opens the compose outlook email, the problem I am facing is that (screenshot below) under the "to" field it is grabbing everything inside the code:

JSON:
{
  "$schema": "https://developer.microsoft.com/json-...",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding": "12px"
      },
      "txtContent": "=if(@currentField, @currentField, 'Need Email')"
    },
    {
      "elmType": "a",
      "style": {
        "text-decoration": "inherit",
        "color": "#inherit",
        "font-size": "inherit",
        "font-weight": "inherit"
      },
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
           [B][COLOR=rgb(184, 49, 47)] "javascript:navigator.registerProtocolHandler('mailto','https://outlook.office365.us/?&rru=compose&to=@currentField','outlook.office365.us')"[/COLOR][/B]
          ]
        }
      }
    }
  ]
}

1742995580124.png
 
Last edited:
I was able to get it working and providing json code below to help anyone with this issue in the future:

JSON:
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding": "12px"
      },
      "txtContent": "=if(@currentField, @currentField, 'Need Email')"
    },
    {
      "elmType": "a",
      "style": {
        "text-decoration": "inherit",
        "color": "inherit",
        "font-size": "inherit",
        "font-weight": "inherit"
      },
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "=if(@currentField, @currentField, '')",
            "?subject=",
            "Vendor - ",
            "[$field_6]",
            "&body=",
            "Greetings,"
          ]
        },
        "onClick": {
          "operator": "+",
          "operands": [
            "",
            "(function() {",
            "  if (navigator.registerProtocolHandler) {",
            "    navigator.registerProtocolHandler(",
            "      'mailto',",
            "      'https://outlook.office365.com/?rru=compose&to=%s&subject=Hello%20from%20SharePoint',",
            "      'Outlook Mailto Handler'",
            "    );",
            "  } else { console.warn('registerProtocolHandler is not supported in this browser.'); }",
            "})()"
          ]
        }
      }
    }
  ]
}
 

Part and Inventory Search

Sponsor

Back
Top