while getting the multiple sysid from system property returning undefined in script include

krishna761
Tera Contributor

Hi,

 

while getting the multiple sysid's from system property returning undefined in logs from script include.

system property is given in comma separated value.

ex: bbdcc1cd97c6a253afc8,fd0d8141907aa253afb4,7e4dc54597b253af37,4er5ty678793rdf36

var SDgroups = gs.getProperty('ITSM_SD_Groups');
gs.log(SDgroups);
result from log: undefined
 
So i need to use this sysid's to  glideRecord 'sys_user_grmember' table.
Please help me on this.
7 REPLIES 7

Long Duong
Kilo Sage

Hi @krishna761,

 

Have you already define the system property "ITSM_SD_Groups"? If not yet, please define it in the sys_properties table.

Otherwise, please attach your existing code.

 

Thanks

ViswaSunny
Tera Contributor

How are you placing the sys ids in system property? 
if it is in obj format then you need to use JSON.parse(gs.getProperty())

Hi,

comma separated

ex: bbdcc1cd97c6a253afc8,fd0d8141907aa253afb4,7e4dc54597b253af37,4er5ty678793rdf36

can you use this kind of code for your scenario and try:

var getGrp = gs.getProperty('ITSM_SD_Groups');
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());
}
}