Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I'm new to FileMaker. What is the field calculation for automatic correction of a phone number?

For example, if a user enters the phone # 0123456879. I want the field to automatically adjust the numbers with the parentheses around the area code w/ 1 space after the parentheses.

Here what I want it to look like (012) 345-6789. I want the field to automatically update entries to look like that.

Thanks!

Posted

The built-in manual/"FMP Help" states:

The following example removes all text from the provided data, then formats the remaining numbers in the preferred phone number formatting:

Let(phone = filter(theField;"0123456789");"(" & left(phone;3) &

")" & middle(phone;4;3) & "-" & middle(phone;7;4))

If theField contains Work: 408.555.1212 this calculation returns (408)555-1212.

Hope that helps.

Posted (edited)

Are they always 3 digit extensions?

If so this should work fine.

/* Strips out any not numeric characters then;

Takes a 7 digit phone number and formats it as (918) xxx-xxxx [color:red](918) is our local area code

Takes a 10 digit phone number and formats it as (xxx) xxx-xxxx

Takes a 13 digit phone number and formats it as (xxx) xxx-xxxx ext. xxx

[color:blue]phone_number is my field name

*/

Let ( digits = Filter ( [color:blue]phone_number ; "0123456789" );

Case (

Length ( digits ) = 7;

("([color:red]918) " & Left ( digits; 3 ) & "-" & Right ( digits ; 4 ));

Length ( digits ) = 10 ;

("(" & Left ( digits; 3 ) & ") " & Middle ( digits; 4 ;3 ) & "-" & Right ( digits ; 4 ));

Length (digits) = 13

("(" & Left ( digits; 3 ) & ") " & Middle ( digits; 4 ;3 ) & "-" & Middle (digits; 7; 4) " ext. " & Right ( digits ; 3 ));

Length ( digits ) = 0 ;

("") ))

I think thats right!

[color:green]ALSO...IN CASE NO ONE HAS MENTIONED IT...

SET THE CALC UP AS AN AUTO-ENTER CALCULATED VALUE AND UNCHECK THE "DO NOT REPLACE EXISTING VALUE FOR FIELD"

Edited by Guest
CLARIFICATION

This topic is 7011 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.