tiagomacul
Giga Sage

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. 

find_real_file.png

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.

find_real_file.png

 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
 find_real_file.png 01. Navigate to sys_properties.list
find_real_file.png 01. Click New
find_real_file.png

02. Type fields on minimum the name and value (to use on future)

 

what means each field you'll find HERE (Offical doc)

find_real_file.png 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
 find_real_file.png 01. Property created
find_real_file.png

02. Navigate to try it

>> System definition > Scripts - Background

 find_real_file.png 03. Type the code gs.print(gs.getProperty("u_my_propery"));
 find_real_file.png  04. Run Script
 find_real_file.png  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

Comments
Vinayak Belgaon
Mega Guru
Mega Guru

That's a good article Tiago.

To add, 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.

 

Regards

Vinayak

Miguel Donayre
ServiceNow Employee
ServiceNow Employee

I think it's crucial that you add this link, and it explains what each field is used for when setting up a new system property. You are missing that complete in your explanation, and there is no link to reference it. 

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/reference-pages/tas...

The SN Nerd
Giga Sage
Giga Sage

Two things I would add

  • 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!
tiagomacul
Giga Sage

added, tks

tiagomacul
Giga Sage

added, tks

tiagomacul
Giga Sage

added, tks

Gabor10
Mega Guru

Never heard of this API, great to learn something new. 

 

Up until now I've always tackled this issue by using a very simple function in a Client Callable Script Include and returning the Property Value via GlideAjax

 

 

getPropertyClient: function() {

return gs.getProperty(this.getParameter('sysparm_property_name'));

}

 

 

The SN Nerd
Giga Sage
Giga Sage

I didn't know about that one!

wilkinson
Mega Explorer

This ServiceNow Community article provides a comprehensive overview of system properties, emphasizing their role as constant values that persist until updated. It highlights the 'sys_properties' table where all properties are stored, accessible via the 'sys_properties.list' command. The guide details how to create new properties, retrieve their values using gs.getProperty(), and underscores best practices like avoiding hard-coded values in scripts. A notable tip is understanding the 'Ignore Cache' setting, which determines whether changes to a property should flush all server-side caches, impacting performance. ServiceNow

Version history
Last update:
2 weeks ago
Updated by:
Contributors