If_v2 | ${BooleanVariable} == true

What is the proper way to store a boolean value?

Because this does not work

store | true | BooleanVariable
if_v2 | ${BooleanVariable} == true

{
  "Name": "Testing",
  "CreationDate": "2020-7-25",
  "Commands": [
    {
      "Command": "store",
      "Target": "TRUE",
      "Value": "BooleanVariable"
    },
    {
      "Command": "if_v2",
      "Target": "${BooleanVariable} == true",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "TRUE",
      "Value": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}

The default vars of ui vision save in automatically boolean value.

Only some vars have the boolean values need to store it without a particular code

These are boolean value vars saved in ui vision rpa

!STRINGESCAPE true
!ERRORIGNORE true

This is not a boolean value store in ui vision

MyVar “true”

Boolean stored value have NOT “”

Technically you’re not storing a boolean variable, you’re simply storing the string “TRUE” which you’re then comparing to the word true. The reason why it isn’t working is because you’re storing “TRUE” and comparing it to “true” which is false because of the capitalization. Make sure you’re always using the same capitalization throughout your variables and stored values.

I’m not a complete expert on this, but the only times I’ve used boolean checks in UI.Vision is with the use of one of the verify commands followed by if_v2 | ${!lastCommandOK} == true.

As mentioned above, you’re storing a string, not a boolean value. Specifically, the string “TRUE”.

One way to store a true boolean is to use executeScript_Sandoboxed:

{
  "Command": "executeScript_Sandbox",
  "Target": "return true",
  "Value": "true_bool"
},

This way, you can return and later compare the value of true_bool against other variables.

{
      "Command": "executeScript_Sandbox",
      "Target": "return true",
      "Value": "true_bool"
    },
    {
      "Command": "if_v2",
      "Target": "${true_bool} === true",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "true boolean",
      "Value": "#shownotification"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }

Do notice I’m using three equal signs, or strict equality comparison. UI Vision converts if_v2 content to JS under the hood to evaluate the expression, so using abstract equality comparison (==) is pointless if you’re trying to true booleans (you might as well use the string “true” if you keep using ==).

Depending on what you need, there might be no need for a ‘true’ boolean and the string will suffice, it’s up to you though.

Further reading on the topic above: Equality comparisons and sameness - JavaScript | MDN

1 Like

Works for me, i know that the post is old, but still having the same problem, and i want to refresh the idea, thanks.

@avarela What issue do you have exactly?

I can`t store boolean’s with store command. The only way that i found is this example.