Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7358 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I need help writing a script (if possible) to convert telephone numbers. I often import data and number may come in as:

2128542583

(212) 854-2583 etc.

I want script to change to 212-854-2583

I'm willing to edit script as necessary depending on what format I'm importing. Since this same phone field may contain international, etc. I would rather handle with script than calc field:

find all entries with xxxxxxxxxx (10 characters) and replace with xxx-xxx-xxxx for example.

Hope this makes sense.

Posted

I scarfed this auto enter calculation replaces existing value calc from somewhere. You can modify to your needs.

// Make phone number into "XXX-XXX-XXXX"

Let(

CONTACT_PHONE_NUMBER = Filter(CONTACT_PHONE_NUMBER;"0123456789");

Left(CONTACT_PHONE_NUMBER;3) & "-" & Middle(CONTACT_PHONE_NUMBER;4;3) & "-" & Middle(CONTACT_PHONE_NUMBER;7;4))

Posted

I think it's prettier to add parentheses around the area code, so in this case the second line above would be

"(" & Left(CONTACT_PHONE_NUMBER;3) & ") " & Middle(CONTACT_PHONE_NUMBER;4;3) & "-" & Middle(CONTACT_PHONE_NUMBER;7;4))

Posted

I tried to use this and it didn't work. How exactly do you get this work? I am a rookie.

Do you use two fields for each one?

Home phone, Homephone2(with calc in it)

Work Phone, Workphone2(with calc in it)

If that is the case, the user enters the number in the first field, and what I want displayed shows in the other field.

I have 3 phone fields and it would be great if when they entered the number, once they tabbed out of it, it changed into the correct format.

Thanks Dave

Posted

Hi David,

Here is a file I made up for you that shows how to script the Format. Because this was done on a Mac and you are on a Windows, it may be necessary for you to Enlarge the Fields to see some of the data.

HTH

Lee

cool.gif

ScriptedPhoneFormat.fp5.zip

Posted

In 7, it can be an auto-entered text field with the calculation above and 'Do not replace existing value' deselected. It will update whenever the field is modified and doesn't require an additional calculation field.

Posted

Hi David,

I didn't pick up on the fact that you were using v7, for some reason, until -queue- responded.

I could send you an explanation of what the global field "g_Raw_Temp" is there for, but if I were you, I would take advantage of any and all v7's new features, and follow -queue-'s advice.

Lee

cool.gif

Posted

Lee,

Yes, please provide more info. The auto enter will work fine for future entries, but I still need to clean up what's in DB.

Thanks,

David

Also, does not appear that the auto enter will work for international numbers as these are cut off to 10 digit numbers.

Posted

Take a look at Business Tracker. It has a telephone number autoenter calculation that works with internation numbers. It has a number of different formats based on the country.

This topic is 7358 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.