My Dynamic Filter Option is not working

jordimsant
Tera Guru

I have written a Dynamic Filter Option as seen in the following image:

jordimsant_0-1756909741509.png

The function you can see in the script is defined in TMNReferenceQualifier script include as follows:

getMyAssetManagementDepartmentGroups: function() {
		var myGroups = gs.getUser().getMyGroups();
		var groupArray = [];
		for (var i = 0; i < myGroups.size(); i++) {
			var group = myGroups.get(i);
			groupArray.push(group); // aquí ja tens el sys_id del grup
		}
		var groupQueryString = groupArray.join(',');
		
		var resultArray = [];
		var department = new GlideRecord('cmn_department');
		department.addEncodedQuery('u_associated_groupIN' + groupQueryString);
		department.query();
		while(department.next()) {
			resultArray.push(department.getValue('u_associated_group'));
		}
		return resultArray;
	},

If I try this code in a Background Script it returns the correct sys_ids it should, but when I try to use it as a filter in the alm_asset table it shows in the breadcrumbs as (empty)

jordimsant_1-1756909922693.png

Can anybody see which error am I doing? I have looked at some others OOB DFOs but they seem to follow similar structures as mine.

 

Thanks for everything!

 

2 REPLIES 2

Rafael Batistot
Tera Sage

Hi @jordimsant 

 

May you try 

 

script include.


getMyAssetManagementDepartmentGroups: function() {
var myGroups = gs.getUser().getMyGroups();
var groupArray = [];
for (var i = 0; i < myGroups.size(); i++) {
var group = myGroups.get(i);
groupArray.push(group); // group is already a sys_id
}
var groupQueryString = groupArray.join(',');

var resultArray = [];
var department = new GlideRecord('cmn_department');
department.addEncodedQuery('u_associated_groupIN' + groupQueryString);
department.query();
while (department.next()) {
resultArray.push(department.getValue('u_associated_group'));
}

// FIX: return as comma-separated string
return resultArray.join(',');
},

 

reference qualifier 

 

javascript&colon; new TMNReferenceQualifier().getMyAssetManagementDepartmentGroups()

 

I have already tried this solution and it is not working