Removing users from the groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago - last edited a week ago
Hello,
The requirement is to create a catalog item to remove the users from the groups. I have attached all the screen captures from PDI. Groups (that user is member of) need to populate only when user is selected;however, it is auto populating on its own. Any help would be gretly appreciated.
My Script include - When I used this SI in catalog client script it is working;however, as an advanced reference qualifier, it isn't.
var GetGroups = Class.create();
GetGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic:function(){
return true;
},
getUsersGrp: function(user_id) {
var dataArr = [];
// var user_id = this.getParameter('sysparm_user_id');
var gr_Grp = new GlideRecord('sys_user_grmember');
gr_Grp.addQuery('user', user_id);
gr_Grp.query();
while (gr_Grp.next()) {
dataArr.push(gr_Grp.group.name.toString());
}
// return dataArr[0].groups_list.getDisplayValue();
// return dataArr[0].groups_list.toString();
// return JSON.stringify(dataArr);
return 'sys_idIN'+ dataArr.join(',');
},
type: 'GetGroups'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hello @SathiskumarD
Ok, what is the issue now?
Is data filtering correctly?
what is the issue left, display in list collector?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
No it is not. I attached script include and List collector variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
When using this in an advanced reference qualifier the filter breaks if user_id isn't provided. You need to put in a check for a valid user_id.
var GetGroups = Class.create();
GetGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic:function(){
return true;
},
getUsersGrp: function(user_id) {
//try adding this
if (!user_id) {
return 'sys_idINnone';
}
var dataArr = [];
// var user_id = this.getParameter('sysparm_user_id');
var gr_Grp = new GlideRecord('sys_user_grmember');
gr_Grp.addQuery('user', user_id);
gr_Grp.query();
while (gr_Grp.next()) {
dataArr.push(gr_Grp.group.name.toString());
}
// return dataArr[0].groups_list.getDisplayValue();
// return dataArr[0].groups_list.toString();
// return JSON.stringify(dataArr);
return 'sys_idIN'+ dataArr.join(',');
},
type: 'GetGroups'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
If you are returning a query for sys_id then sys_id values need to be in the array. the While loop loads the group name, not the group's sys_id.
while (gr_Grp.next()) {
dataArr.push(gr_Grp.group.name.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday - last edited Wednesday
Hello @SathiskumarD , Try this
Script include:
var userGroups = Class.create();
userGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserGroups: function(user) {
var data = [];
var grpGr = new GlideRecord('sys_user_grmember');
grpGr.addQuery('user', user);
grpGr.query();
while (grpGr.next()) {
data.push(grpGr.group.toString());
}
return 'sys_idIN' + data.join(',');
},
type: 'userGroups'
});
In List collector variable:
List table: sys_user_group
Reference qualifier: javascript: new global.userGroups().getUserGroups(current.variables.user_to_be_removed);
Variable attributes: ref_auto_completer=AJAXTableCompleter,ref_ac_columns=name,ref_qual_elements=user_to_be_removed
Portal View:
Platform View:
Mark this as correct if this resolves your issue.
