The CreatorCon Call for Content is officially open! Get started here.

Store values in JSON format

SnowUserDev
Tera Contributor

Hey Community,

 

How can we Store values in JSON format in servicenow in system properties. I want to store multiple values in a single property.

 

Thanks

3 ACCEPTED SOLUTIONS

Danish Bhairag2
Tera Sage

Hi @SnowUserDev ,

 

U can do something like this.

 

{

"key1":"value1",

"key2":"value2",

"key3":"value3"

}

 

Thanks,

Danish

 

View solution in original post

Hi @SnowUserDev ,

 

U can create a property of type string n then put the values in the above format.

 

Thanks,

Danish

 

View solution in original post

Stefan Georgiev
Tera Guru

Hello @SnowUserDev ,

if you share your case, we might find another solution than storing in a property.
you can store it in a string property, just go to Properties and store you JSON in a string property type record.

When you are getting the property anfte you use gs.getProperty('<your_JSON_property') use an JSON.parse

var prop = gs.getProperty('<your_JSON_property')
va yourObject = JSON.parse(prop)

 

/*you logic here with the Object*/

Hope that this helped, if it does you can mark it as helpful and accept the solution.

All the best, 
Stefan

View solution in original post

9 REPLIES 9

Danish Bhairag2
Tera Sage

Hi @SnowUserDev ,

 

U can do something like this.

 

{

"key1":"value1",

"key2":"value2",

"key3":"value3"

}

 

Thanks,

Danish

 

Hi @Danish Bhairag2 ,

 

What will be the type of the property?

 

Thanks

Hi @SnowUserDev ,

 

U can create a property of type string n then put the values in the above format.

 

Thanks,

Danish

 

Hi @Danish Bhairag2 ,

 

Thanks so much for replying so quickly. Could you be kind enough to tell me how can I call or use the property in a script.

 

Thanks