Problem: I’m attempting to trap whether the user has filled two global fields, return an error message if either is empty, proceed if both have values.
This kind of thing is dead easy in FMP. I’ve been struggling with this for hours, getting nowhere.
If (globals.field == null ) //check if null
or
If (globals.field) //check if globals.field is NOT empty or null
or
If (!globals.field) //check if globals.field is empty or null
For instance if you create a record en fill nothing in that field, than that field is null. If you type something and save it, and than manually delete the string you typed, than the field is empty!
If (globals.field) //check if globals.field is NOT empty or null
or
If (!globals.field) //check if globals.field is empty or null
Very strange.
If (globals.field) //evaluates the same whether there’s content in the field or not. The “globals” part of the fieldname displays in green.
If (!globals.field) //also evaluates the same whether there’s content or not. However with the presence of the “!” the whole fieldname displays in black.
Just one addition: you don’t need to do if (…) {} twice.
You can also do:
if (…)
{
…
}
else
{
…
}
See the samplecode for these functions under the Flow node in the Servoy Editor
Paul
Morley: for more explanation on null’s and empties: Search the forum. There has been more discussion about this. This difference is a typical “feature” of all SQL Databases
pbakker:
Just one addition: you don’t need to do if (…) {} twice.
You can also do:
if (…)
{
…
}
else
{
…
}
See the samplecode for these functions under the Flow node in the Servoy Editor
Unless I’m looking in the wrong place, samplecode is greyed out for all items under the Flow node in the Servoy Editor. I’m going to JSLib → Flow → ifelse → Move Sample.
pbakker:
That is the right place, do you have a method open to move the sample code to?
Yes, open method. I can Move Code but not Move Sample. This is true for all items in Date, String and Flow. Math items have both enabled, but Move Sample does exactly the same thing as Move Code.
R2 2.0.3 build 276.
Same both Mac and PC.
By the way, I didn’t really get (understand) the “twice” example.
pbakker:
OK, I’m mixing up names again: On some Items you just hae Move code and on others you also have move SampleCode.
Sometimes the function is so simple, samplecode would just be a little bit overdoing it, don’t you think?
Paul
Agreed.
There are times when I’m assuming things are more complicated than they actually are. Coming from FMP, all those braces look a bit intimidating at first, but really it’s just the same thing.
Starting cold, no prior JavaScript, no other “languages” than just FMP, it’s disorienting, so much to learn. Like learning to walk for the first time.