what is wrong

Viewing 6 reply threads
  • Author
    Posts
  • July 25, 2021 at 6:45 PM #44858

    Tim Flick
    Participant

    Shouldn’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 Moffatt
    Participant

    I’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 Flick
    Participant

    Actually, 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 Moffatt
    Participant

    Just 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 Flick
    Participant

    Thanks works, I just needed to change the results order

    July 27, 2021 at 7:25 AM #44866

    Tim Flick
    Participant

    What this same calculated field look like in a script Thanks much

    July 27, 2021 at 4:17 PM #44868

    Sam Moffatt
    Participant

    As 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: class is a reserved word in Javascript so not a valid variable name.

    The fld-fieldid1 is 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.

Viewing 6 reply threads

You must be logged in to reply to this topic.