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.

gs.getProperty does not return boolean for a value field of sys_properties - Support and Troubleshooting - Now Support Portal
- Condition - “gs.getProperty(Property name) ” executing the script for both the True/False values: STEPS TO REPRODUCE: - Navigate to scripts - Background - Execute the following script: if(gs.getProperty(‘assignment_workbench.new.window’)){

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