Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to call array from my system property?

saint
Tera Expert

Hi everyone,

I'm working with a system property that stores an array of string values, for example:

Property: list.of.strings
Values: "111 - TEST", "112 - Test2"

In my Script Include, I'm retrieving the property like this:

 

var titles = gs.getProperty('list.of.strings');

 

I’d like to use these values to query a table with GlideRecord and filter records based on them.

Has anyone done this before or knows the best way to parse and use these property values in a GlideRecord query?

Thanks!

13 REPLIES 13

SAPSnEnthusiast
Tera Contributor

Hi @saint 

Have you tried JSON.parse method

yashkamde
Kilo Sage

Hello @saint ,

 

First of all stored the values in total string format -> "111 - TEST,112 - Test2" (comma seperated),
depending on how you’ve stored it. To work with it as an array, split it:

var titlesArray = titles.split(',');

 

so after retriving you will get as -> ["111 - TEST", "112 - Test2"]

 

Then use it according to your requirement in gliderecord :

var gr = new GlideRecord('<table>');
gr.addQuery('your_field', 'IN', titlesArray.join(','));
gr.query();

while (gr.next()) {
    //perform your further operation
}

 

 

If my response helped mark as helpful and accept the solution.

 

I do have lots of values with "," in the values like "111- Test,One", "112- Test,Ten", that's the reason i'm unable to use this.

So then you will have to stored it in a structured way in the way they can be retrieved.

i.e you can stored it in json and then parse it in json.parse so that they can be utilized as an object..