The CreatorCon Call for Content is officially open! Get started here.

Reference qualifier for catalog variables Call the script include with

nakamura323
Kilo Guru

I have a catalog item with three variables: employee_company, employee_department and employee_group.

All types are references.

 

I would like to narrow down the choices for employee_group by the selected results for employee_company and employee_department.

Specifically, perform a query using the Question Choice string selected by employee_company and employee_department.

 

However, the script include and its calls that I am currently creating are not working well. Furthermore, it is necessary to reflect the selection results of not only employee_company but also employee_department. Please tell me how to improve it.

 

script include:

Accessible from: All application scopes

Client callable:✔
Active:✔
 
var test_IdDepartmentUtil = Class.create();
test_IdDepartmentUtil.prototype = {
    GetComNamQuery: function(ComNam) {
    var gr = new GlideRecord("sys_user_group");  
    gr.addQuery('Name', 'CONTAINS', ComNam );
    gr.query();
    var list=[];
while (gr.next()){
list.push(gr.Name.toString());
    }
return 'sys_idIN' + list.toString();
},
    type: 'test_IdDepartmentUtil'
};

Reference qualifier:
javascript:'active=true^' + new test_IdDepartmentUtil().GetComNamQuery(current.variables.employee_company);
 
Thank you.
 
1 REPLY 1

Harish KM
Kilo Patron
Kilo Patron

Hi @nakamura323 there is a error in your script include . The backend name of servicenow fields are in lowercase. I added active true to the query, you need to return sysid

 

GetComNamQuery: function(ComNam) {
var gr = new GlideRecord("sys_user_group");
gr.addQuery('name', 'CONTAINS', ComNam );
gr.addQuery('active','true');
gr.query();
var list=[];
while (gr.next()){
list.push(gr.getValue('sys_id'));
}
return 'sys_idIN' + list.join(',');
},

javascript:new test_IdDepartmentUtil().GetComNamQuery(current.variables.employee_company);

Regards
Harish