Unable to validate True/False false property in flow designer

Kumar38
Kilo Sage

I have a flow designer on Property table that need to validate the value of a T/F type property . The results seems inconsistent.

 

I created a flow designer variables of type True/False .

 

For 1st validation , I assigned flow variable "propertyValue"  the value of system property using  return Boolean(fd_data.trigger.current.value); 

 

After X amount of time waiting , it needs to validate again .

For 2nd validation. I used the below script to set the value for  flow variable "propertyValueAfter" .

 

var grSys = new GlideRecord('sys_properties');
if(grSys.get('xxxxxxxx')) //SysId of property
{
return Boolean(grSys.value); //Script prints correct value.
}

The issue here is although flow variables have the correct value , the If condition in flow always seem to validate them as true .

 

 


 

 
 
 
1 ACCEPTED SOLUTION

Kumar38
Kilo Sage

I modified my flow to use script to set the value as "active " based on True or false. and then use that new value in if condition.

 

If value = active , instead of value = true or false.

View solution in original post

2 REPLIES 2

OlaN
Giga Sage
Giga Sage

Hi,

You cannot validate a string to boolean in this manner.

The conversion will always return true if the variable has some value.

So you will need to do the comparison in some other way.

Example below

var someText = 'hello';
var boo = Boolean(someText);
// boo will be set to true, since someText has a value

var someText2 = '';
var boo2 = Boolean(someText2);
// boo2 will be set to false, since someText2 has no value

// instead do a comparison something like this

var someVariable = gs.getProperty('someProperty');
if (someVariable && someVariable == 'true')

 

You can learn more on the Boolean method here:

https://www.w3schools.com/js/js_booleans.asp

Kumar38
Kilo Sage

I modified my flow to use script to set the value as "active " based on True or false. and then use that new value in if condition.

 

If value = active , instead of value = true or false.