Javascript on an interactive filter ?

Domenico Nolfi
Giga Contributor

Good morning all,

I'm here to ask you if, on a dashboard,  it's possible to use a javascript to add an additional filter on a interactive filter, such as the option "advanced" of a "Reference Specification" for a form.

The current filter is created with a "cascade filter" and there is only the option to filter according to a specific filter.

Thanks in advance,

Domenico

3 REPLIES 3

sachin_namjoshi
Kilo Patron
Kilo Patron

yes, you can add custom interactive filter to add JS in script include.

 

https://developer.servicenow.com/app.do#!/event/creatorcon18/CCW1161/creatorcon_18_CCW1161_create_cu...

 

Regards,

Sachin

Domenico Nolfi
Giga Contributor

Hi all.  Many thanks for your help but I'm a bit lost because i don't find the correspondences between the guides and my interface.

 

I have to create an interactive filter with this javascript code, already used on a form

var Confirmed_Owner_dep_contain = Class.create();
Confirmed_Owner_dep_contain.prototype = {
    initialize: function() {
    },
	
	getValue: function(){

	var ownerDepts = [];
	var userRec = new GlideRecord('sys_user');
    userRec.get(gs.getUserID());

	//gs.print(userRec.name);

	var var_department = userRec.department;
	//gs.print('dept: ' + var_department);
	
	//Recupero della struttura di coordinamento associata al dipartimento dell'utente
	var coord1 = new GlideRecord('sn_audit_containment_coordination');
	coord1.addQuery('u_owner_dept', var_department);
	coord1.query();

	if(coord1.next()){
	//gs.print('coord1: ' + coord1.u_owner_dept.name);
	//gs.print('coord1: ' + coord1.u_coordinator_dept.name);
					
	//Recupero dei dipartimenti associati alla struttura di coordinamento dell'utente
	var coord2 = new GlideRecord('sn_audit_containment_coordination');
	coord2.addQuery('u_coordinator_dept', coord1.u_coordinator_dept);
	coord2.query();

	//gs.print('count: ' + coord2.getRowCount());

	while(coord2.next()){
		ownerDepts.push(coord2.u_owner_dept.toString());
		//gs.print(coord2.u_owner_dept);
	}
		//gs.info( ownerDepts.join(',').toString());
		return 'sys_idIN' + ownerDepts.toString(); //join(',');
	}	
	
	return '';
},

    type: 'Confirmed_Owner_dep_contain'
};

 

Currently, i have this interactive filter on the field "u_confirmed_owner_dept" of the table "Remediation Action" , but the list box drop down all records. I wish that this list will be filtered by the Javascripts logic (already used and working on a form).

find_real_file.png