Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms 5 › what is wrong
- This topic has 6 replies, 2 voices, and was last updated 4 years, 4 months ago by
Sam Moffatt.
-
AuthorPosts
-
July 25, 2021 at 6:45 PM #44858
Tim FlickParticipantShouldn’t the conditional below require both conditions be met
IF([Class]=”Std” & [YPS]>3.64;””;”?”)
thanks Tim
July 26, 2021 at 12:08 AM #44859
Sam MoffattParticipantI’m not sure the equals operator works properly with strings and always returns a true.
Try
IFEQUAL, e.g.IFEQUAL([Class], "Std", 1, 0)instead of[Class]="Std".July 26, 2021 at 3:45 AM #44861
Tim FlickParticipantActually, this doesn’t address the question because two conditions have to be met in order to be true. You only addressed one condition
July 26, 2021 at 7:22 PM #44863
Sam MoffattParticipantJust to double check, this didn’t work?
IF(IFEQUAL([Class], "Std", 1, 0) & [YPS]>3.64;"";"?")In the minor testing I did with a calculation field (by the way don’t forget to set it to text on the bottom left of the editor from the default of number), this seemed to work:
IF(IFEQUAL("TEST", "TESTX", 1, 0) & 2 > 1; "", "?")If I change either of the two conditions (e.g. make the IFEQUAL fail or the greater than), then the flag shows up.
July 27, 2021 at 4:03 AM #44865
Tim FlickParticipantThanks works, I just needed to change the results order
July 27, 2021 at 7:25 AM #44866
Tim FlickParticipantWhat this same calculated field look like in a script Thanks much
July 27, 2021 at 4:17 PM #44868
Sam MoffattParticipantAs a script it’d be something like this:
function Flag() { var classtype = record.getFieldValue("fld-fieldid1"); var yps = record.getFieldValue("fld-fieldid2"); return (classtype == "Std" && yps > 3.64) ? "" : "?"; } return Flag();Note:
classis a reserved word in Javascript so not a valid variable name.The
fld-fieldid1is the ID of the field, the script editor can help you generate a line for that (double click field on desktop or on mobile there is a field picker) with the variable name and field ID preset. You can also get the field ID from the form editor when you select the field to splice in the ID yourself.You don’t need the full function wrapper but I find it feels more natural to do the return statement. The return is using a ternary operator to do the comparison compactly.
-
AuthorPosts
You must be logged in to reply to this topic.