Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



Posted on 2004-08-23
Medium Priority
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 172 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 164 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 164 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!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
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…
Loops Section Overview
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

564 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