Jump to content

PhoneFormat ( Phone ; Format )


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

Recommended Posts

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.

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 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
Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

This topic is 4206 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
 Share

×
×
  • Create New...

Important Information

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