Trying to get the group names in Assignment group variable which requested for belongs to
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 08:32 AM
Hi ,
Get list of groups thats Requested for belongs to in a catalog form variable called Assignment group I have written script include and onChnage catalog client as below but some how it's not setting the values in the refernce variable and also am able to get the sys_ids's of all the groups from script include but its not setting it in the reference variable
Note: This is in scoped application not in Global scope
Script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:43 AM
Hi @raj99918 ,
Key Point :
1. assignment groups - list collector - sys_user_grmember table.
2. Create client callable si
3. Please change the backend name according to your requirement
In script include declare array and push sysid and add .tostring() like below code.
Script include:
var getRequestedForDetail = Class.create();
getRequestedForDetail.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroupDetail: function() {
var sysID = this.getParameter('sysparm_id');
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',sysID);
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.group.name.toString());
}
// gs.info('line number 15 ' + arr);
return arr.toString();
},
type: 'getRequestedForDetail'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 12:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 12:04 PM
Hi @raj99918 ,
Try both and check which is working in your case.
Please mark this comment as Correct Answer/Helpful if it helped you.
Thanks & Regards,
Sumanth meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 12:19 PM
Hi @Sumanth16 First you have shared me one thread in that they are using table as sys_user_group but not the sys_user_grmember am confused now which table I need to use ? Please confirm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:16 AM
Yes @raj99918 ,
pass current.variables.requested_for in the function parameter and make changes in the SI function as below -
getGroups: function(user) {
var groups = [];
//var user = this.getParameter('sysparm_userID');
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user);
gr.query();
while (gr.next()) {
groups.push(gr.group.sys_id);
}
return 'sys_idIN' + groups;
},
Please Accept the solution(s), if they are helpful!