QuickBase Scripting & Data Field Validation

  • 1
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I understand that there is ability to use ... is it Javascript? ...scripting in QBase to accomplish things that are not straight out of the UI.  

First question, is this Javascript or something else?

Second is, where is some info on how to use JS to add functionality.  I know JS but not how it fits into QBase.

Third is, the problem at hand for me is to do some field level numeric validation to eliminate common input errors in forms.  Is this the way to do it, with JS?  Or is there some other method.

I am an software engineer but just learning QBase for a customer project.  My searches aren't producing much in the way of "where do I start"?  All I really need is a pointer and example or two and I'm off to the races.

Thanks for any help!!!

Stephen
Photo of Stephen Rogers

Stephen Rogers

  • 150 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,280 Points 50k badge 2x thumb
If you can give an example of the validation rules, there may be a simple way to create a formula which calculates if the data is valid.  Then you can have a form rule to block the save if the data is not valid.
Photo of Stephen Rogers

Stephen Rogers

  • 150 Points 100 badge 2x thumb
For a numeric field, ability to limit to, say, a range between 91.5 and 94.8.
Or integer between 0 and 99.
Or...  etc.

If you type in something wrong it either stops you or pops up an error.  Typical validation stuff.

I know that some stuff like typing alpha characters into numeric is already handled.

What's a formula...?  I'll go check that out in the user guide.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,280 Points 50k badge 2x thumb
An example of a formula is a formula field called Valid? of type formula checkbox

IF([entry field] >=91.5 and [entry field] <= 94.8,true, false)

which is equialent to
IF([entry field] >=91.5 and [entry field] <= 94.8,true)

which is also equivalent to 

[entry field] >=91.5 and [entry field] <= 94.8

ie with a boolean you can make a statement and the system either says its true or called Bullshit on you and says its false.
Photo of Stephen Rogers

Stephen Rogers

  • 150 Points 100 badge 2x thumb
Great - I'll look up formulas and give this a try!  Sounds promising.

Thanks so much.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,280 Points 50k badge 2x thumb
Photo of Stephen Rogers

Stephen Rogers

  • 150 Points 100 badge 2x thumb
Wow that is truly handy!  Formula wielding folks, follow that link...!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,280 Points 50k badge 2x thumb
When you go to build a formula, there is also a help in the box, but this info is all in one place, so you
get a nice overview of all the formulas.

Also check out the Help text on formula variable. it makes your fomulas more readable.
http://help.quickbase.com/user-assistance/#formula_variables.html?Highlight=formula variables
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
This is Dan D's "library" of all sorts of .js add-ons for QB.

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=td

if you want to use a js page automatically you will want to start with the "Image Onload" Technique.  But most everything can run with a button click.
Photo of Rahul Gangwar

Rahul Gangwar

  • 110 Points 100 badge 2x thumb
Dear Stephen, There is alternative to achieve this requirement using javascript.

Please follow below steps.
1. First Configure Dan's Image onload technique.
2. https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=294&_ga=2.233694235.40686674...
3. In your module.js code page ,  you can write javascript function as below to validate the character length in any numeric field. In field fid_147. if user enters digit more than or less than 6 then it will prompt error and clear the value from the same field.
---------------------------------------------------------------------------------------
$('#_fid_147').focusout(function(){ 
if ($('#_fid_147').val() != '' && $('#_fid_147').val().length != 6) { 
alert('The PID should be 6 character');
$('#_fid_147').val('');
$('#_fid_147').focus();

});
---------------------------------------------------------------------------------------
$('#_fid_16').focusout(function(){ 
if ($('#_fid_16').val() != '' && $('#_fid_16').val().length != 8) { 
alert('The FW# should be 8 character');
$('#_fid_16').val('');
$('#_fid_16').focus();

});
---------------------------------------------------------------------------------------
I hope this will help you.

Regards,
Rahul
(Edited)