I wish to create a script which searches one Number field. If there is nothing there then use another Number field. However, if the first number may have nothing in it (not even a zero), but I cannot work out the search criteria for an empty number field.
For example:
if (upper_figure == ”) {
return total_charge_with_fixed_amount;
}
does to produce the desired result if the upper_figure is empty. Nor does
if (upper_figure == null) {
return total_charge_with_fixed_amount;
}
What is the correct syntax for an empty Number field?
Try if (upper_figure == undefined || upper_figure == "") {
Daniel,
Thank you again.
Brendan,
Could you put on the relevant help pages information on searching for nothing for different types of field? It is not easily found and confuse beginners in Javascript. I am used to searching in other apps for nothing with either ” or “” but these do not necessary work with TapForms for some field types.
If you’re after checking if something isn’t “falsy” then you could simplify it to if (!upper_figure) {
and JavaScript will convert it for you automatically. Per that falsy page though, it will treat zero as false.
Some of the nuance is that if you haven’t set a value on a field then it is undefined
because it hasn’t been set yet. Tap Forms for many field types maps directly to JavaScript data types. JavaScript will do some amount of type coercion which may result in unexpected results.