logo

NJP

Servicenow property / properties

Import · Jan 11, 2022 · article

Servicenow property / properties

What's property?

  • It's a constant value occurring continuously over a period of time (until updated by someone or something-code)

----

  • gs.getProperty() does not work in client callable scripts
  • There is an undocumented API called GlideProperties
  • * This can be used to retrieve System Properties in client callable scripts
    • This can even be used to call some hidden system properties!

How do I see properties in ServiceNow?

Most of the system properties can be found in your left navigation under the 'System Properties' application as shown above.

image

ALL of the properties in the system are stored in the 'sys_properties' table and can be viewed and edited there by typing 'sys_properties. list' into the left navigation filter.

image

what's properties is it Available on the system?

On the previous list you'll see all properties instead of this list you can consult oficial documentation "Available Properties".

How do you create a property in ServiceNow?

Image Description
image 01. Navigate to sys_properties.list
image 01. Click New
image 02. Type fields on minimum the name and value (to use on future) what means each field you'll find HERE (Offical doc)
image 03. Click Submit

How do I get property value in ServiceNow?

For sample was created a property "u_my_propery" and we'll use it in fact the method/command gs.getProperty

Description
image 01. Property created
image 02. Navigate to try it >> System definition > Scripts - Background
image 03. Type the code gs.print(gs.getProperty("u_my_propery"));
image 04. Run Script
image 05. Your Result

ServiceNow Best Practices:

Avoid using hard-coded values in scripts instead user properties.

One of the most important check on properties is the Ignore Cache which is always ignored by most of us, but its important to understand the importance of it.

Just putting the excerpt from the docs site here because it is very well explained.

Ignore cache The system stores system property values in server-side caches to avoid querying the database for configuration settings. When you change a system property value, the system always flushes the cache for the sys_properties table. Use this field to determine whether to flush this property's value from all other server-side caches. The default value of false causes the system to not ignore flushing caches, which results in flushing all server-side caches and retrieving the current property value from the database. Set this field to false when you want to ensure all caches have the current property value. The true value causes the system to ignore flushing some server-side caches, which results in only flushing the cache for the sys_properties table and preserving the prior property value in all other caches. Set this field to true to avoid the performance cost of flushing all caches and retrieving new property values. Typically, you should only set this field to true when you have a system property that changes more frequently than once a month, and the property value is only stored in sys_properties table.

image

summary

System properties

Avoid using hard-coded values in scripts.

Hard coding sys_ids makes the system more difficult to manage, and less able to move functionality ...

Do not use hard coded sys_id

View original source

https://www.servicenow.com/community/now-platform-articles/servicenow-property-properties/ta-p/2307691