Sharepoint List (Tel and Mail Hyperlinks)

Greg Spinks 0 Reputation points
2023-03-13T15:41:07.13+00:00

Hi all, new to this place so please afford me a moment.

Sharepoint List

I've found methods on how to add a href to an email address. My main aim though is to use a column for email addresses + tel numbers. I basically have 3 columns named 'Comms 1, Comms 2 and Comms 3' - as the communication method will vary per vendor/org on the list with how much or how little information is available.

 

I currently have this for email - Sharepoint 365 - Adding clickable email to list - Microsoft Community Hub

 

 I wish to have a 'tel' condition, too and use both. So if the current field has a telephone number, then the 'tel' href will apply. If it is an email address, then the mailto href will apply (a conditional formatting json)

Please could someone give me some tips on how to accomplish this :)

Thank you :)

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,606 Reputation points Microsoft External Staff
    2023-03-14T10:45:15.65+00:00

    Hi @Greg Spinks ,

    Per my test, the following Json code can be used in a column alone.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "txtContent": "@currentField",
      "attributes": {
        "href": "='tel:' + @currentField"
      }
    }
    
    

    03141

    But when I set the conditions, the effect is not very good, it cannot be performed as expected. You can use this method as a workaround first, I will continue to do some research, and I will update it as soon as there is any progress.

    Thanks for your understanding!

    Updated on 3/15/2023

    You can use this code make conditions.

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "a",
    "txtContent": "@currentField",
    "attributes": {
    "href": "=if(indexOf(@currentFeild, '@')<0, 'tel:' + @currentField, ' mailto:' + @currentField)"
    }
    }
    

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.