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 !!


Who is Participating?
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
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:

prifre: try it also, you'll like it.
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.

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.
Split it.
gurshaanAuthor Commented:
Thanks Guys

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

Thanks again
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.