If Condition... expressions.
Can someone elaborate for me what type of conditions work or what they expect... I am missing something simple.
For example:
$value1.result = "Hello world"
What is the simple way to test for non-null, or non-empty...
I assumed JS so i tried:
=$value1.result
False
and then negated that...
=!$value1.result
False
and then negated that...
=!!$value1.result
True
-
$value1.result = "Hello world" // Evaluates to undefined // This is actually assigning a value to $value1.result. The If activity is expecting a Boolean value so it treats undefined as false. $value1.result == "Hello world" // Evaluates to true or false // Use double equals to test for equality. This is what you will want in most cases $value1.result // Evaluates to the string value of result // The If activity is expecting a Boolean value so it treats it as false !$value1.result // Evaluates to false // In JavaScript !(some string value) evaluates to false !!$value1.result // Evaluates to true // This is just negating the previous expression !(!$value1.result) is the same as !false which is true
--Ryan
0 -
So I want to test that $value1.result is not empty and null, how would you achieve that? the double-negative?
the screenshot is valid for the UI, but it either isn't converted into a 'true/false condition' or maybe evaluates to false for a different reason?
0 -
sorry re-read your first response and you do note it evaluates to false because its a string...
I saw the link in the IF activity help to : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
I tried: =Boolean($value1.result) as per the links suggestion, but that didn't seem to do anything ... likely 'custom java' problem.
0 -
To check if a string value is not empty and not null you want to use:
!!$value1.result
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer