Hoppa till huvudinnehållet

If Condition... expressions.

Kommentarer

4 kommentarer

  • Ryan Cooney
    $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
  • Permanently deleted user

    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?

    8-17-2017 8-16-10 AM

     

    0
  • Permanently deleted user

    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
  • Ryan Cooney

    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.