Hi @Volesini Matej ,
For example, I created a single line of text column, when an e-mail address is entered, I would like the column to display a clickable mailto: link. When a phone number is entered, I would like it to be formatted (000) 000-0000.The display effect is as follows( You can change the JSON according to your specific needs):
You can use following JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "a",
"style": {
"padding-right": "8px",
"display": "=if(indexOf(@currentField,'@') > -1, 'block','none')"
},
"txtContent": "@currentField",
"attributes": {
"target": "_blank",
"href": {
"operator": "+",
"operands": [
"mailto:",
"@currentField"
]
}
}
},
{
"elmType": "span",
"style": {
"overflow": "hidden",
"text-overflow": "ellipsis",
"padding": "0 3px",
"display": "=if(indexOf(@currentField,'@') > -1, 'none','block')"
},
"txtContent": "=if(indexOf(@currentField + '^', '^') == 10,'('+substring(toString(@currentField),0,3)+') '+substring(toString(@currentField),3,6)+'-'+substring(toString(@currentField),6,10),if(indexOf(@currentField + '^', '^') == 7,substring(toString(@currentField),0,3)+'-'+substring(toString(@currentField),3,8),@currentField)",
"attributes": {
"class": ""
}
}
]
}
Reference Link: https://sharepoint.stackexchange.com/questions/303082/json-to-make-a-sharepoint-list-column-accept-a-phone-number-and-or-an-e-mail-add
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.