Forum Discussion
Sharepoint 365 - Adding clickable email to list
- Aug 04, 2022
jacobite Yes, it is possible to convert the text field to clickable text in list view using column formatting. Follow below steps:
- Create a single line of text field in your list to enter email address.
- From list view, select column name header, select "Column settings" and then select "Format this column".
- Click on "Advanced mode" from right side panel.
- Copy-paste below JSON on textbox by removing existing JSON and click Save
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "@currentField", "attributes": { "href": "='mailto:' + @currentField" } }
Output:
Documentation: SharePoint column formatting
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
ganeshsanap This is helpful, but now, if the user clicks on the same field and it is empty, Outlook opens up. How do I make it so that it only adds mailto: on fields that are not blank?
I wanted to make a text field as a clickable mailto link, but only if it was not blank. Here's the code I used (under List Settings>Edit Column>Column Formatting)
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "=if(@currentField == '', '','Send E-Mail')",
"attributes": {
"href": "=if(@currentField == '', '','mailto:' + @currentField)"
}
}
- ganeshsanapMay 26, 2023MVP
markm4g You can also use below JSON instead which shows/hides the anchor element based on the value of current column:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "@currentField", "attributes": { "href": "='mailto:' + @currentField" }, "style": { "display": "=if(@currentField, 'block', 'none')" } }
OR
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "@currentField", "attributes": { "href": "='mailto:' + @currentField" }, "style": { "display": "=if(@currentField != '', 'block', 'none')" } }
Related read: SharePoint JSON formatting: Check if column is blank/empty
Please consider giving a Like if my post helped you in any way.