Need help getting values from two system properties and store in array

Nasir1
Tera Expert

Hi Guys,

 

I need help with the following script, not sure why its not working? I have two system properties ignoreclients and ignoreServers, that have few comma separated values, what I am trying to achieve is get the values from both system properties and store them in ignoreClientsServers array which I am going to use in my flow as an output, but when I run the following script I am only getting system property values of one of the properties not both, please help.

 

 

var ignoreClientsServers = []
var sysprop = new GlideRecord('sys_properties');
sysprop.addEncodedQuery('nameSTARTSWITHignoreclients^ORnameSTARTSWITHignoreServers');
sysprop.query();

while (sysprop.next()) {

ignoreClientsServers.push(sysprop.value);
}

gs.print(ignoreClientsServers)

 Thanks

Nasir

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

while pushing into array use toString()

var ignoreClientsServers = [];
var sysprop = new GlideRecord('sys_properties');
sysprop.addEncodedQuery('nameSTARTSWITHignoreclients^ORnameSTARTSWITHignoreServers');
sysprop.query();
while (sysprop.next()) {
    ignoreClientsServers.push(sysprop.value.toString());
}

gs.print(ignoreClientsServers);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

while pushing into array use toString()

var ignoreClientsServers = [];
var sysprop = new GlideRecord('sys_properties');
sysprop.addEncodedQuery('nameSTARTSWITHignoreclients^ORnameSTARTSWITHignoreServers');
sysprop.query();
while (sysprop.next()) {
    ignoreClientsServers.push(sysprop.value.toString());
}

gs.print(ignoreClientsServers);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ahhh perfect thank you so much, that worked, Ankur for the rescue once again, thank you so much mate!!!

Glad to help.

Please mark response helpful as well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

done