Can we store different type of value in a single system property
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Everyone
I wanted to store values such as "1", "one", "One" (digit & Alphabet) in a single system property.
Can this approach is feasible??
Thanks in advance
Utsav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
What is your exact use case for this? I think we can store it, as we have a property where multiple assets can be stored in one property. It really depends on your specific use case.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello, @Dr Atul G- LNG See, my usuage is like--
Here, the variable "va1" can have any value like---1, one, One, 2, Two, two etc.
And I have created a system property with:-
Type as String
Value as---{"1","one","One","2","Two","two"}
but based on the above mentioned code, it is not working.
Need suggestions
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Yes — a system property in ServiceNow is always stored as a string, so you can save "1", "one", and "One" in the same property (usually comma-separated or JSON format). But the platform won’t automatically interpret them as different types; you’ll need to parse and handle them in your scripts.
Feasible, but not recommended if you need multiple formats. Better to define one consistent format or use multiple properties.
It’s not a good practice.
System properties are meant to hold a single, consistent value (string, boolean, number, or JSON). Mixing different formats like "1", "one", "One" in the same property makes your scripts harder to maintain, error-prone, and confusing for others
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Yes, this is feasible in ServiceNow. Use JSON format in a system property.
Example Setup:
System Property: x_custom.number_mapping
Value: {"1":"one","2":"two","3":"three"}
Script to Get Value:
// Get system property and parse JSON
var mappingJson = gs.getProperty('x_custom.number_mapping');
var mapping = JSON.parse(mappingJson);
// Usage
var result = mapping['1']; // Returns: "one"
gs.info(result);
Benefits: Easy to maintain, supports multiple formats, centralized configuration.