Understanding gs.getProperty in ServiceNow: A Practical Guide
- ericpark68
- Mar 17
- 2 min read
Updated: Mar 29

ServiceNow administrators and developers frequently encounter scenarios requiring dynamic configurations that avoid hard-coded values. The gs.getProperty() function in ServiceNow provides an effective solution by enabling scripts to fetch system property values at runtime. This article clarifies what gs.getProperty() is, its importance, and how it can simplify script maintenance and improve flexibility.
What is gs.getProperty?
The gs.getProperty() method belongs to the GlideSystem API, used server-side to retrieve the value of system properties stored within the sys_properties table. It always returns property values as strings, even if the stored value is a number or Boolean. Additionally, it allows specifying a default value to be returned if the requested property does not exist.
Example usage:
var apiUrl = gs.getProperty("integration.api.url", "https://default.url.com");
Common Use Cases
Integration URLs: Avoid hard-coding URLs by storing them in system properties.
Feature Toggles: Dynamically enable or disable features without modifying scripts directly.
Thresholds and Limits: Configure numeric or date-based thresholds.
Step-by-Step Guide: Finding Property Values
Navigate to System Properties > All Properties (sys_properties.list).
Search for the exact property name used in your script.
Click on the property to view details and its current value.
Troubleshooting Common Issues
Empty Values: Verify the property name is accurate and exists.
Boolean Confusion: Always explicitly compare boolean properties (gs.getProperty("prop.name") == "true").
Scope Issues: Ensure property names are prefixed correctly, especially in scoped applications.
Practical Examples
Example 1: Email Sender Configuration
var senderEmail = gs.getProperty("glide.email.username");
gs.log("Email sender configured as: " + senderEmail);
Example 2: Using Feature Toggles
if (gs.getProperty("notify.incident.update") == "true") {
gs.info("Incident update notifications are enabled.");
// Notification logic here
}
Alternative Approaches
Custom Tables: Suitable for managing more complex configurations.
Application Properties: Scoped applications might benefit from dedicated modules.
gs.setProperty: Used for programmatically managing system properties. (Requires admin privileges and may not take effect immediately due to caching; use gs.flushProperties() if an immediate update is needed.)
Conclusion
Utilizing gs.getProperty() significantly enhances your ServiceNow scripts by promoting maintainability and flexibility. Regularly audit scripts to replace hard-coded configurations with dynamic properties and document each property clearly to facilitate easier management and troubleshooting.