Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PhoneFormat ( Phone ; Format )

Featured Replies

Name & Parameters: [color:red][big] PhoneFormat ( Phone ; Format ) [/big]

Description: The Format parameter, enclosed in quotes, can be changed to any series of pound signs (representing numbers) and other characters for separators. Any length phone number or format can be used due to the nature of the recursive custom function allowing a single calculation to format international and domestic numbers. Even numbers with extensions can be used.

Sample Input:

9093934664

Results:

(909) 393-4664

Recursive: yes

Formula:

Case(



not IsEmpty(Format);



Let(



[

NumbersOnly = Filter (Phone; "0123456789");

NewFormat = Left(Format; Length(Format) - 1);

NewNumber = Left(NumbersOnly; Length(NumbersOnly) - 1)

];



Case(

Right(Format; 1) = "#";

PhoneFormat(NewNumber; NewFormat) & Right(NumbersOnly; 1); 

PhoneFormat(NumbersOnly; NewFormat) & Right(Format; 1) 

)



)



)







 

Required Functions:

Author(s):) John Mark Osborne

Date: 04/27/06

Credits: John Mark Osborne

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

  • 2 months later...
  • Newbies

When I use this script, the formatting characters, such as '(', ')', and '-' are replaced with the letter 't'. I've tried several options, including using the backslash before the formatting characers, but nothing seems to work. Any ideas?

  • 2 months later...

Hi Man,

StarFangledNut

I think whit a Filter. Fun :

  • 4 weeks later...

I don't know what I'm doing wrong here but when I try to save the CF I get "There are too few parameters" error message at the areas marked in red. Also are the Function Parameters those marked in Blue?

Case(

not IsEmpty([color:blue]Format);

Let(

[color:blue]NumbersOnly = Filter ([color:blue]Phone; "0123456789");

[color:blue]NewFormat = Left(Format; Length(Format) - 1);

[color:blue]NewNumber = Left(NumbersOnly; Length(NumbersOnly) - 1)

];

[NewFormat = Left(Format; Length(Format) - 1);

NewNumber = Left(NumbersOnly; Length(NumbersOnly) - 1)

];

Case(

Right(Format; 1) = "#";

PhoneFormat(NewNumber; NewFormat[color:red]) & Right(NumbersOnly; 1[color:red]);

PhoneFormat(NumbersOnly; NewFormat) & Right(Format; 1[color:red])

[color:red])

[color:red])

[color:red])

Edited by Guest
tighten things up

  • Newbies

I have a database of about 20,000 records I just imported from a .dbf file. I need to have the phone fields show up as (xxx)xxx-xxxx. I have the formula that will work with all new entries, but how do i get it to work on the 20,000 records i just imported. I have tried to write a script, but have been unsuccessful so far.

If your field type is Text, and you are using the Auto Enter Option with a Calculation, then Change the field to a calculation. Close the Define Field Box, FileMaker will update the field, and then you can go back into Defind Fields and change it back to Text. This isn't the case, please let me know more about the field involved.

Lee

  • 1 month later...

Hello i have inserted the custom function in to define/custom functions and all was accepted, but i do not know how to get it to work, i guess i click my telephone fields and then what :) sorry for such a noob question

  • 3 years later...
  • Newbies

Hi all,

M. Osborne's solution is working very well .. but I have a problem with "() -" on the field when phone number field is empty ???

I create the zip attach .fp7 file. This file need, at least, FM10 to work. As you will see, phone formatting is dynamic and formatting is done as soon user enter a number. Each number entered by user is followed by an automatic formatting.

But the solution is very "big" .. it need 2 fields and 1 complicated script.

Is there a easier solution to have dynamic and real time phone format formatting on FileMaker ?

Thanks !

François

Test_PhoneFormat.fp7.zip

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.