Skip to main content
Question

I need a formula to format a numeric field to show like this 051.801.264/0001-85

  • February 2, 2018
  • 0 replies
  • 160 views

I have a numeric field that is a tax id number field, and the format is all the same.
051.801.264/0001-85
It has dots and dashes and a slash. Some customers use only numbers and others use the dots and symbols when filling out.

Is there a formula that can be helpful here in this case?

xxx.xxx.xxx/xxxx-xx

I have seen fields that it starts to add the dashes and dots automatically as you start typing.
I appreciate all the help?
This topic has been closed for replies.

  • Quickbase Alumni
  • February 2, 2018
So easy:

Tax ID Auto Format ~ Add New Record
https://haversineconsulting.quickbase.com/db/bnfj79i2f?a=nwr

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=620

Notes:

(1) I did this pretty fast and there are a few things to add. The script is responding to keyup events so if you were to paste a string into the field it will not apply the formatting.

(2) You can enter a misplaced "." ,  "-" or "/" character and it will not be disallowed

(3) maybe some other weird edge cases but they are easy to fix.

  • Quickbase Alumni
  • February 2, 2018
FWIW, I wrote that script while binge watching old episodes of  CSI Miami (I'm a big fan of David Caruso) and if the script had my full attention there are a number of improvements I could easily have made to it.

In fact, there are libraries such as Square's FieldKit that could be used which do all the hard work for you:

Square's FieldKit Library
https://github.com/square/field-kit/releases

Check out the demo:

FieldKit Demos:
http://square.github.io/field-kit/

But why stop with using a mere professionally developed library - how about building this feature into your version of QuickBase? After all, are we not Builders?

Here is how you might approach the challenge. Just use a Service Worker to  splice a new section into the Field Properties page asking for the necessary properties to define a Validation Rule (shown here as a single conceptual property Mask):




There are some additional details of where you would store the supplemental information in the Validation Section  (perhaps in a code page appropriately named and linked to the field). Or perhaps your might arrange to define and store the information in the form where the Validation Rule is used on a case by case basis.

Turns out this is exactly how the WQuzat people of Flubus 5A evolved their QuickBase technology using a concept they called QuickBase Plugins!


Sergio,
Try pasting this into a simple formula text field. It converts the string to all numbers and then inserts the delimiters back into the string.

Change [Raw input] to your field name.


var text MyString = [Raw input];

var text PartOne = Part($MyString,1, "./-");
var text PartTwo = Part($MyString,2, "./-");
var text PartThree = Part($MyString,3, "./-");
var text PartFour = Part($MyString,4, "./-");
var text PartFive = Part($MyString,5, "./-");

var text AllNumbers = List("",$PartOne,$PartTwo,$PartThree,$PartFour,$PartFive);

Left($AllNumbers,3)
& "."
& Mid($AllNumbers,4,3)
& "."
& Mid($AllNumbers,7,3)
& "/"
& Mid($AllNumbers,10,4)
& "-"
& Mid($AllNumbers,14,2)