ServiceNow Boolean System Properties not working
A quick one for you today.
If you find that you have created a Boolean system property and the value is not returning as expected, it may be due to the following issue.
System Properties of type Boolean remain as a String when running them in comparisons, so your best bet is to check for both "types" by using the following methods.
var propValue = gs.getProperty("myPropertyName");
if(propValue == "true" || probValue == true){
gs.info("My Property is True!");
}
Additionally, if you need your system property to always return a default value even if the property value is muddled or empty or the wrong type, you can do the following.
var propValue = gs.getProperty("myPropertyName") || false;
// || false will default the value to boolean false if the property is empty or does not return properly