Search code examples
filemaker

How do I prevent users to use thousands separator in FileMaker Pro?


In FileMaker Pro, when using number field, the user can choose to use a thousand separator or not. For example, if I have a database with a field for the price of an item, the user can either enter 1,000 or 1000.

I am using my database to generate an XML file that needs to be uploaded. The thing is, that my XML scheme dictates that only a value of 1000 is allowed and not 1,000. Therefore, I want to either automatically remove the comma, or (my preference in this case) alert the user when trying to enter a value with a thousand separator.

What I tried is the following.

For the field, I am setting Validation options. For example:

  • Require Strict data type: Numeric Only
  • Validated by calculation: Position ( Self ; ","; 1 ; 1 ) = 0
  • Validated by calculation: Self = Substitue ( Self, ",", "")
  • Auto-enter calculation: Filter( Self ; "0123456789." )

Unfortunately, none of these work. As the field is defined as a number (and I want to keep it like this, as I am also performing calculations based on this number), the Position function and the Substitute function apparently ignore the thousand separator!

EDIT: Note that I am generating my XML by concatenating a string, for example:

"<Products><Product><Name>" & Name & "</Name><Price>" & Price & "</Price></Product></Product>"

The reason is that what I am exporting is dependent on the values in my database. Therefore, I am not using the [File][Export records...] function.


Solution

  • Auto-enter calculation will work, but you need to uncheck the box "Do not replace existing value of field" (which is checked by default).

    I'd suggest using the calculation GetAsNumber(self) as the auto-enter calc. If it should only contain integers, wrap that in a call to Int()