How to call array from my system property?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @saint ,
Try this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
If you trying to do assume each value has two parts try this script. I used Code and Description but you can change those and set them to other things as well not just gs.info.
var titles = gs.getProperty('list.of.strings');
if (titles) {
var titlesArray = titles.split(',');
for (var i = 0; i < titlesArray.length; i++) {
var value = titlesArray[i].trim();
gs.info('Full Value: ' + value);
// Optional: split number and description
if (value.indexOf(' - ') > -1) {
var parts = value.split(' - ');
var code = parts[0].trim();
var description = parts[1].trim();
gs.info('Code: ' + code);
gs.info('Description: ' + description);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You can use the split value as '","'
