AnsweredAssumed Answered

swedish phone number format

Question asked by JohnEriksson on Feb 19, 2013
Latest reply on Feb 22, 2013 by JohnEriksson

Title

swedish phone number format

Post

     To be able to search phone numbers they need to be stored with only numbers, no dashes or characters. As most phone numbers starts with a single 0 I've chosen text but only allowing numeric content. But, when I want to show the phone number I want it to be formatted with dashes and spaces. It can be ####-### ## or ##-## ## ## or ###-### ### ##

     The problem is the dash, where the number before the dash is the area code. There is no logical rule in sweden where the dash should be. So, I've imported a list of all area codes (about 270 posts) in a separate table and made a relation (x). 

     Now the fun part. How would the calculation for the calculation field that shows the formated phone number look like? Is there a way to match the area code from the separate table to the beginning of the phone number?

     The only way I can think of is to make a script with a loop and match from the top to the bottom until I might find something and save that in a separate text field and trigger this script when leaving the phone number field. That is slow, and won't work when importing. Any better ideas?

Outcomes