Forum Discussion

SergioSergio's avatar
SergioSergio
Qrew Cadet
8 years ago

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

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?
  • 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.
    • SergioSergio's avatar
      SergioSergio
      Qrew Cadet
      My friend, you are awesome!
      I have been following all your information, and I try to use most of your material, but I think I am not so smart when it comes to quickbase.

      I am creating a field url formula, I paste your code there, but it always shows me error messages. I think i need to learn still how to apply all your codes, which fields to use etc.

      Is there a video somewhere that i could learn how to use your codes in my applications? I have searched the whole internet and cant find one that shows me the step by step. Or a guide would work too.
      Thank you so much and enjoy your show!
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      Many of my solutions involve using JavaScript which is not the same as QuickBase's formula language. The problem you are having is that you are attempting to paste my JavaScript code directly into the formula definition. 

      The way to use the script is to set up a special rich text field and place it on the form using a technique called the image onload technique (IOL technique) and described here:

      https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=294

      There are hundreds of similar scripts in the pastie database which use the IOL technique (and other scripting techniques). If you need help beyond the resources in the forum or the pastie database you can ask further questions here and I will answer as time permits or you can contact me directly using the info in my profile:

      https://getsatisfaction.com/people/dandiebolt
    • SergioSergio's avatar
      SergioSergio
      Qrew Cadet
      Thank you so much. I left you a message on your phone number and also texted you.
      I guess I am stuck in the 1st step where i need to insert a "user defined variable". Can you give me a hint here? i feel after that i will be able to follow the other steps.
      Thank you!
  • 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)
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      .. the age old tension between native and script, man and machine, love and heartbreak rears its head ...
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      I�m at the airport now with time before my flight so I felt compelled to give Sergio an easier way as I can see he is trying so hard. Off now for a ski week.
    • SergioSergio's avatar
      SergioSergio
      Qrew Cadet
      Enjoy the snow my friend! 
      I have been losing all my hairs trying to get this done. But I know once i learned the first one, I will be able to implement the other ones.

      I will use yours for now, but I am challenged to get this accomplished now.

      Lets see if i understood:

      1- I followed all the instructions and I created the user iol and /iol
      2- I created the page module.js and added the long script where shows what page I am working on.
      3- I created a normal text field named [taxid].
      4- I need to create a field name [iol] & "module.js" & [/iol] ? 
      5- Is number 4 correct? or i just need to paste that "[iol] & "module.js" & [/iol]" into a another field text formula type? 

      Anyways, I wont give up on this one yet, but for now I will use Marks proposal so I can at least have something working today. 
      Thanks for both of you!