how do I calculate a field in ArcGIS to display a phone number?

3085
8
01-18-2018 02:52 PM
Labels (1)
ThomasTagliaferri
New Contributor

how do I display a phone number format (123) 456-7890 in a Web Map pop-up that was originally formatted as numeric?

Tags (1)
0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

A phone number can't be numeric, but text/string

"(123) 456-7890"

CarmelConnolly
Esri Regular Contributor

Hi Thomas, 

You'll be able to achieve this by using Arcade in the pop up:

  1. Make an expression to return the first 3 digits of the number: Left($feature.FieldName_, 3)
  2. Make an expression to return the middle digits of the number: Mid($feature.Number_, 4, 3)
  3. Make an expression to return the last 4 digits of the number: Right($feature.Number_, 4)
  4. Use a Custom Attribute Display and add the 3 expressions but seperate them using the brakets and hypen:
  5. The pop up will look like this:

Help:

Text Functions | ArcGIS for Developers 

Text Functions | ArcGIS for Developers 

Text Functions | ArcGIS for Developers 

Configure pop-ups—ArcGIS Online Help | ArcGIS 

Carmel

XanderBakker
Esri Esteemed Contributor

You will have to use the Custom Attribute Display (as Carmel Connolly  indicated), but the html content should be like this:

<a href="tel:5551234567">Call (555)123-4567</a>

... to make it clickable and to be able to make the call. You can use a single expression to make the display text and use the content of the field just after "tel:" is the field just contains the digits.

CarmelConnolly
Esri Regular Contributor

Oh cool! 

BillHeigh
Occasional Contributor

Hi @XanderBakker ,

I have been trying to create an expression for this in Map Viewer Beta and I copied and pasted your example above but I keep getting this error:  "Parse Error:Line 4: Unexpected token <"

Any thoughts or ideas?

Thanks, Bill~

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @BillHeigh ,

Can you share what data you have (data) and what you are trying? The example I posted should be changed in order to include the field with the phone number. It just represents what the resulting HTML should look like. Not sure if it will show up as a link in the Map Viewer Beta.

 

0 Kudos
BillHeigh
Occasional Contributor

Hi @XanderBakker ,

Sure can, it is this:

<a href="tel:$feature["gs39039_DBO_gs_service_point__4"]">Call (555)123-4567</a>

Just to keep it simple I didn't do any additional formatting. I did play around with the quotes as I thought they may conflict with my field name, but I kept getting the same error when I tested it.

Cheers, Bill~

0 Kudos
DanPatterson_Retired
MVP Emeritus

Oh now I see what you want to do.

Field calculator in arcmap or Pro

add an integer field (long, short)

substitute 'a' for !YourFieldName! in line 3 below.

a = "(123) 456-7890"

int("".join([i for i in a if i.isdigit()]))

1234567890