using extensions in phone number fields - e.164 format

shembop
Tera Contributor

I have our phone number fields in the e.164 format, and now someone needs to add an extension (phone# - ext)

How can I do this without adding a field? Multiple down sides of just adding a field.

3 REPLIES 3

Brad Tilton
ServiceNow Employee

I don't think that field type supports extensions, so you're probably stuck with an additional field for the extension.


kevan_smith
Mega Expert

This is an old thread, but I'm prepping for Notify/Twilio and had the same question.  In the end I came to the same conclusion as Brad but adding the "why" here.  Hopefully it saves someone a bit of time.

The e.164 field is technically a string field and you can make it as long as you want.  However, when you edit the field, country codes, long distance codes, and non-numerics all get stripped, and the result gets passed through the Telephone Display Rules.  So... for each of your Phone Territories you can add a Phone Format that allows for the extension.  For example:

<format>($1) $2-$3 x.$4</format>
<name>US availableFormats</name>
<order>120</order>
<pattern>(\d{3})(\d{3})(\d{4})(\d+)</pattern>

What that does is take any number after the 10th digit and assumes it's part of an extension, right or wrong. 

Here's the rub...

  1. Since all non-numerics (such as ",") get stripped, you can't introduce wait periods (which is a limiting factor for some extensions)
  2. According to the official ITU E.164 recommendation, the phone number must be number up to fifteen digits in length starting with a ‘+’.  That's not enough space for extensions, and assuming this is for Notify (e.g. Twilio), that's a real problem.  Twilio strictly follows the e.164 standard.

What you can do is send Twilio the regular e.164 compliant phone number, and then pass it the extension/waits/etc after the receiver picks up.  You can probably parse your modified e.164 phone number before handing off to Twilio, but that's getting a bit too deep in the weeds for me.  Easier and more reliable to just use an additional field for the extension, as Brad so succinctly suggested. 

Thanks Kevan for this answer !