Sunday, December 08, 2013

ServiceNow - when the "true|false" type isn't

Let's say you have a system property defined in ServiceNow with a type of "true | false".

To access the property, you find the gs.getProperty() call at http://wiki.servicenow.com/index.php?title=GlideSystem#getProperty.28String.2C_Object.29.  You then have something like:
var isValue = gs.getProperty("some.true-false.property");

if (isValue) {
  gs.log("is true");
} else {
  gs.log("is false");
}
What's the bug in the code?
gs.log(typeof isValue)
returns "string".

gs.getProperty() will always return a string value.  Instead of it being documented at the link above, you can see this in the table dictionary definition and it is documented at http://wiki.servicenow.com/index.php?title=Adding_a_Property.

Maybe I'm just old but I really don't like dynamically typed languages, especially when you have almost no debugging environment to speak of.

No comments: