How to fetch the details of list collector in a list collector variable

Samiksha2
Mega Sage

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!

7 REPLIES 7

manjusha_
Kilo Sage

@Samiksha2 

 

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

Hi @manjusha_ ,

yes. Now if I am selecting one user. Role is populating, but for multiple select, roles are not autopopulating.

@Samiksha2 

If you want roles of all users then you have to use sys_user_has_role table

 

Thanks,

Manjusha Bangale

Role is a custom drop down field with options in the u_hardware table.