Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Can we store different type of value in a single system property

UTSAV KUMAR JAI
Tera Contributor

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

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @UTSAV KUMAR JAI 

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]

****************************************************************************************************************

Hello, @Dr Atul G- LNG  See, my usuage is like--

var va1 = "one";
    var mappingJson = gs.getProperty('test.qwerty');
    var mapping = JSON.parse(mappingJson);
    if (va1 == mapping) {
        gs.addInfoMessage("System Property is working");
    }

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
Utsav

Rafael Batistot
Kilo Patron

Hi @UTSAV KUMAR JAI 

 

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

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

Ajay_Chavan
Kilo Sage

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.

Glad I could help! If this solved your issue, please mark it as ✅ Helpful and ✅ Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****