Rules using "is between" / "is not between" and negative numbers

Forums Dynamic Forms for SharePoint Rules using "is between" / "is not between" and negative numbers

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 2 months, 3 weeks ago.

  • Author
    Posts
  • #23967

    Eric Dickerson
    Participant

    I have a rule that is using the qualifier of “Is not between”… see image, but here is the set up for the rule:

    TempField
    Is Not Between
    {fieldA}-{FieldB}

    This works fine with a value of -1000 for fieldA and a value of 1000 for FieldB, AS LONG AS TempField is a POSITIVE number… if a negative number is entered into TempField, the rule does not understand the use of Negative numbers. So, if I entered -20 into the temp field it would make the rule true, but it should be false because -20 IS NOT between -1000 and 1000.

    I tested this with actual numbers rather than field internal name references and got the same result. (Note it may be worth mentioning in the contextual help that you can use field names in curlyBrace in the value field for this method)

    I tested with IS between and IS NOT between… same issue with both.

    Seems like a bug, maybe I am missing something.

  • #23982

    Alexander Bautz
    Keymaster

    Hi,
    You are right, there is a bug with negative numbers in general with this trigger. I’ll fix this in the next release and hopefully get it out during this week / weekend.

    You can make a workaround using a custom function like this in your Custom JS:

    function compareTemp(){
        var match = false;
        var min = Number(getFieldValue("minTemp"));
        var max = Number(getFieldValue("maxTemp"));
        var trigger = Number(getFieldValue("triggerTemp"));
        if(trigger >= min && trigger <= max){
            match = true;
        }
        if(!match){
            spjs.dffs.alert({
                "title":"Not within number range",
                "msg":"The number " + trigger + " is not in the correct range: " + min + " to " + max
            });
        }
    }

    Call this function from a rule triggering on change on the input field. Change minTemp, maxTemp and triggerTemp field names to match your FieldInternalNames.

    Alexander

You must be logged in to reply to this topic.