1

Using SharePoint online in office 365.

According to the Microsoft docs "Add an action button to a field" it is possible to render a Mail IconName including quickActions element to open email when clicked. Now I do not want to use the email address of a Persons column, but instead I would like to use the formatting JSON on a text column (e.g. Title) with the action directing to a standard mail address [email protected]:

In the list settings of the Title column with the JSON formatter, I place the following JSON code:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding-right": "8px"
            },
            "txtContent": "@currentField"
        },
        {
            "elmType": "a",
            "attributes": {
                "iconName": "Mail",
                "style": {
                    "text-decoration": "none"
                },
                "class": "sp-field-quickActions",
                "href": {
                    "operator": "+",
                    "operands": [
                        "mailto:[email protected]"
                    ]
                }
            }
        }
    ]
}

But nothing happens, so my first question is what is currently going wrong?

Then I would preferably only render this Mail icon and apply this quickAction, when the given date of another column, let's say Final date is still in the future. So preferably combine it with the example in the Microsoft docs "Formatting an item when a date column is before or after today's date":

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if([$Final Date] <= @now, '#ff0000', '')"
  }
}

1 Answer 1

1

Use JSON code like below for your requirements:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding-right": "8px"
      },
      "txtContent": "@currentField"
    },
    {
      "elmType": "a",
      "style": {
        "text-decoration": "none",
        "display": "=if([$FinalDate] > @now, 'block', 'none')"
      },
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": "mailto:[email protected]"
      }
    }
  ]
}

Output:

enter image description here

2
  • Thank you, I noticed I had my column named Final Date, but when referring to that column you need to remove the space inbetween --> [$FinalDate] Feb 10, 2022 at 10:47
  • 1
    Yes, you have to use internal name of column. Feb 10, 2022 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.