- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2019 05:01 AM
I have a system property that I created to holds a list of sys_ids from the sys_user_group table. They are separated by commas in the system property like so: sysid1, sysid2,sysid3
In using the gs.getProperty function, I'm able to retrieve the values into a string var like so:
var x = gs.getProperty('my_system_property');
My issue is that I need to parse through the result(var x) to pull out all the sys_id's so I can query them via a loop in a script. Does anyone have any suggestions?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2019 06:56 AM
Hi,
We used this:
var getGrp = gs.getProperty('my_system_property');
var spl = getGrp.split(',');
for (var i = 0; i < spl.length; i++){
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',spl[i]);
gr.query();
while(gr.next()){
gs.print(gr.user.getDisplayValue());
}
}
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2019 05:26 AM
You can use the following snippet.
Split the property and then loop over the array.
var x = gs.getProperty('my_system_property');
var aGroups = x.split(',');
for (var i = 0; i < aGroups.length; i++){
var sGroup = aGroups[i];
// Do what ever you want.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2019 06:56 AM
Hi,
We used this:
var getGrp = gs.getProperty('my_system_property');
var spl = getGrp.split(',');
for (var i = 0; i < spl.length; i++){
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',spl[i]);
gr.query();
while(gr.next()){
gs.print(gr.user.getDisplayValue());
}
}
Thanks,
Ashutosh
