How to fetch the details of list collector in a list collector variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 02:14 AM
Hi,
I have created catalog item in which I have a list collector variable -User(u_user--reference to sys_user table). another list collector- Roles(u_roles-reference to u_hardware table).
Here requirement is when we are selecting two value in the User variable the roles should be populated for both two values.
Suppose- User- a and b, then roles of both a and b should populate.
For one User, Roles is populating but for 2 it is not populating.
Script include:
getRole: function() {
var Sysid = [];
var role = this.getParameter('roles');
var gr = new GlideRecord("u_hardware");
gr.addQuery('u_user=' + role);
gr.query();
while (gr.next()) {
Sysid.push(gr.getValue('u_role'));
}
return JSON.stringify(Sysid);
},
Client script:(onChange of User)
var ga = new GlideAjax('getUserRole');
ga.addParam('sysparm_name', 'getRole');
ga.addParam('roles', newValue);
ga.getXML(setProducts);
function setProducts(response) {
var answers = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
g_form.setValue('u_role', answers);
}
Please help in this.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 02:26 AM
You are trying to pass users selected in list collector to script include to get all the roles of all selected users
Is this your requirement?correct me if something different
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 02:47 AM
Hi @manjusha_ ,
yes. Now if I am selecting one user. Role is populating, but for multiple select, roles are not autopopulating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 05:48 AM
If you want roles of all users then you have to use sys_user_has_role table
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 06:12 AM
Role is a custom drop down field with options in the u_hardware table.