Group Members Fetch Issue Using System Property
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Everyone,
"I'm trying to fetch all users from a group, and I’ve written the below Script Include, which is being called in the highlighted value condition. When I use a hardcoded sys_id or group name in the Script Include, it returns the correct result. However, when I replace the group sys_id with a system property, it returns an incorrect result."
//Working code with Hardcoded group name/sys_id value:
var PMI_DEL_sMTGroupUtils = Class.create();
PMI_DEL_sMTGroupUtils.prototype = {
initialize: function() {},
getSMTMembers: function() {
var users = [];
var groupID = "64bc7f942b473254d917f3eff891bf9f";
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("group.sys_id", groupID);
gr.query();
while (gr.next()) {
users.push(gr.getValue('user'));
}
return users.join(',');
type: 'PMI_DEL_sMTGroupUtils'
};
//Code using system properties, which is not working and is giving an incorrect result:
//Code using system properties, which is not working and is giving an incorrect result:
var PMI_DEL_sMTGroupUtils = Class.create();
PMI_DEL_sMTGroupUtils.prototype = {
initialize: function() {},
getSMTMembers: function() {
var users = [];
var smtGroupId = gs.getProperty('pmi_del.smt_group_id'); //Get SMT group sys_id from system property
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("group.sys_id", smtGroupId);
gr.query();
while (gr.next()) {
users.push(gr.getValue('user'));
}
return users.join(',');
},
type: 'PMI_DEL_sMTGroupUtils'
};
I have attached the highlighted value condition below, where the Script Include method [javascript:new PMI_DEL_sMTGroupUtils().getSMTMembers();] is being called. I have also attached the system property named 'pmi_del.smt_group_id' can anyone suggest what's the issue?
I have attached the highlighted value condition below, where the Script Include method [javascript:new PMI_DEL_sMTGroupUtils().getSMTMembers();] is being called. I have also attached the system property named 'pmi_del.smt_group_id' can anyone suggest what's the issue?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
I would check to see what value is being returned when you write the variable of the system property to the log.
