How can I make my phone number column pick up numbers correctly?

Tevon2.0 1,101 Reputation points
2023-02-14T19:15:01.6766667+00:00

SharePoint Server 2019 On Primise

I am trying to set up a column so that when a user adds an item to my SharePoint list; the home phone column will set the inserted number as in the format of (000)-000-0000

I thought to use the formula below but that didn't work.

=TEXT([Home Phone],"(000)-000-0000")

I also tried to set in the rules below to restrict numbers to 10 digits long.

Formula for Phone number column validation

=LEN(Home Phone)=10

User Message for Column Formula

Home Phone Number must be exactly 10 Digits Long

Is it possible to utilize multiple formulas in a column? If not which is a better option for a phone number column?

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,280 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,105 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,773 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,593 questions
{count} votes

Accepted answer
  1. Haoyan Xue_MSFT 21,816 Reputation points Microsoft Vendor
    2023-02-15T02:34:52.39+00:00

    Hi @Tevon2.0 ,

    Set the Home Phone column in the format of (000)-000-0000, which can be achieved through JSON format:

    User's image

    
    {
      "$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",
          "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": ""
          }
        }
      ]
    }
    

    User's image

    The steps to set the Home Phone number must be exactly 10 digits are as follows:

    List settings->Validation settings->=LEN([Home Phone])=10

    User's image

    In this way, at the same time, the Home Phone column can be set in the format of (000)-000-0000 and the length of the restricted number must be 10.


    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.

    10 people found this answer helpful.

0 additional answers

Sort by: Most helpful