• Resolved rotertal

    (@rotertal)


    Hi CodePeople!

    I have two currency fields (fieldname1 and fieldname2) and a calculated field (fieldname3). I want to compare the entries of the currency fields (only if these are filled):

    fieldname3 => IF(fieldname1|r === fieldname2|r),1,0)

    This works nice, however, when I want to put it into the following function, empty currency fields are treated as “0” and therefore result in 1:

    (function() {
    if (fieldname1 !== “” && fieldname2 !== “” && fieldname1 === fieldname2) {
    return 1;
    } else {
    return 0;
    }
    })();

    What can I do?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @rotertal

    The plugin preprocesses the fields’ values to use them in mathematical operations. If you want to access the field’s raw value, use it with the |r modifier.

    Please edit the code as follows:

    (function() {
        if (fieldname1|r !== "" && fieldname2|r !== "" && fieldname1 === fieldname2) {
            return 1;
        } else {
            return 0;
        }
    })();

    Best regards.

    Thread Starter rotertal

    (@rotertal)

    Thank you, now it works!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[NSFW] Comparing two fields (if not empty)’ is closed to new replies.