Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions


Posted on 2004-08-23
Last Modified: 2012-05-05
What function or script I should use for special fields such as phone numbers , social sec numbers.


If I enter phone number    5593512032 in a phone number field, when  I move to next record or exit  then the phone number field should appear as  (559)- 351-2032 or 559-351-2032  and same thing with Socaial Secuirty field  if I enter 603456743 after moving to next record or exiting the last field ( Social secuirty field )should appear as 603-45-6743.

Any suggestions. Help please !!


Question by:gurshaan

Accepted Solution

prifre earned 43 total points
ID: 11878426
Actually this is not so easy. The reason is that FileMaker does not enable you to automatically run a script (that would fix a field contents) after the data have been entered an fix it.

You could use a calculated field that takes the result from the first entered field, and calculates that one so the result looks nice in the calculated field and then just use the Calculated field when displaying the Phone.

Another difference is to enter them in an ugly way and then to manually start a script that would go through all the ugly phone numbers/socnumbers and fix them to be pretty. But that would mean you would have to edit them as pretty and they would be permanent in that field.

Another solution is to use FileMaker only as an engine and to handle everything through serverscripting and via a web-page. But that is something completely different.

So to sum it up - it is not really possible to do it perfectly (display something formatted, but edit unformatted) based on scripting, since FileMaker cannot do that well.
But you can get it nice via buttons and caculated fields when you actually need it (when printing, etc).

hope that helps
with a smile
LVL 28

Assisted Solution

lesouef earned 41 total points
ID: 11886010
I use RunScript.fmx which is a free plug-in which allows to trigger a script when you tab to next field, or click outside it.
So write the formatting script, and trigger it with that stuff. Absolutely magic!
Since I don't remember when I got it from, here is copy: http://extranet.valblor.com/~lesouef/RunScript.fmx

prifre: try it also, you'll like it.
LVL 19

Assisted Solution

billmercer earned 41 total points
ID: 11893984
Lack of good input masks and field formats is probably my biggest gripe about Filemaker. To get the visual effect you describe, this technique works pretty well. This example is for a 10 digit US phone number field called PHONE.

- Create an unstored calculated field called PhoneFmt, make it equal to
"(" & Left(PHONE,3) & ")" & Middle(PHONE,4,3) & "-" & Right(PHONE,4)
- Add this new field to your data entry layout.
- Set the background color of PhoneFmt to the same color as your layout's background.
- In the properties for PhoneFmt, uncheck the "Allow entry into field" option.
- Place the calculated field on top of the original phone number field so it covers it completely.  
Now, when you look at the layout you only see the formatted field that can't be edited. But if you click on it, it highlights the editable field underneath, which then becomes visible. Edit the number, and when you leave the field, the formatted calculation pops on top again, showing the formatted change.
Once you've created this on your layout, group the elements so you can move it around easily.

The hardest part of this is defining the calculation to do the formatting. Hi Voltage has a free plugin that makes this super-easy. If you download it, they also include a sample database that uses the same technique I described above.


P.S. lesouef, thanks for the scripting plugin. I love stuff like that!
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 28

Expert Comment

ID: 11894228
I forgot to mention how it works:
You should use the external function
EXTERNAL("FMcs-CallScript", "[script name]")
in the 'control by calculation' property of the field.
(Names may be wrong, I have the same pb as prifre, not using an english version.)
It does nothing if the field is entered but left unchanged.
LVL 19

Expert Comment

ID: 12203801
Split it.
LVL 28

Expert Comment

ID: 12204490

Author Comment

ID: 13636701
Thanks Guys

I will try all of the options. You guys been very helpful.

Thanks again

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question