1 Reply Latest reply on Jun 26, 2014 5:44 PM by adam RSS
    michaelfr Creator

    Validator

    Hello,

    I am trying to use a validator widget in my mashup. I have the following code but it doesn't seem to work. Not sure how to write the expression in the validator. I have a parameter input to the widget called Expanded.

    if Expanded = False then Output = True else if Expanded = True then Output = False

    Thank you,

    Mike

      • Validator
        adam Creator

        Hi Mike,

         

        The Expression widget expects JavaScript just as our

        Services

        do. You have a couple of options when writing this particular expression – given the small size of the Expression text box, I recommend using the most concise and least error-prone expression possible. Keep in mind, '=' is the assignment operator and '==' is a relational operator which tests for equality. Furthermore, the boolean keywords 'true' and 'false' should be lowercased and there is no 'then' keyword in JavaScript.


        Since Expanded is a boolean value a simple if-else will suffice. You can take advantage of the logical negation operator along with the conditional operator (?) to get a nice short expression:


        !Expanded ? true : false;


        or, if you prefer something closer to what you had:


        if (Expanded == false) { result = true; } else { result = false; }


        Thanks,

        Adam