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
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
Hello Adam,
Just saw this post and was curious to ask weather i can validate the expression below using Validator widget.
(((1-2)*5.797*(((((mA1-4000000)/1000000)+1)-((mA2-4000000)/16000000))^3))+(61.196*(((((mA1-4000000)/1000000)+1)-((mA2-4000000)/16000000))^2))-(218.96*((((mA1-4000000)/1000000)+1)-((mA2-
IF(1000 100;10;20)
)/16000000))))+291.5
1. mA1 and mA2 are replaced with the values later.
2. And also i have used if condition between the expression.
If i cannot achieve the same using validator widget, what is the best possible solution to my problem.
Thanks
Sunay