create a list view module that match the tickets with logged-in user company

Javad Nasserifa
Tera Contributor

Hi there,

I want to create a list view based on [task] table with a dynamic filter.

I want to show all the tickets that are opened by user.company match with logged-in user.company.

 

what should I put in the arguments to address this requirement?

Should I use List of records or URL arguments in the link type?

 

Thank you in advance for any advice.

 

2 REPLIES 2

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Javad Nasserifa 

 

The best way is to create URL Arguments and you can directly mention the condition there.

 

Please reach out to me if you have any questions

 

Regards,

Sai Venkatesh

Bert_c1
Kilo Patron

You can create a Dynamic Filter Option like:

Screenshot 2024-10-10 202706.png

and define a script include:

Screenshot 2024-10-10 202813.png

The script follows:

function myCompanyUsers() {
	var user = gs.getUserID();
//	gs.info('myCompanyUsers: user = ' + user);

	var company = '';
	var foundComp = false;
	var su = new GlideRecord('sys_user');
	su.addQuery('sys_id', user);
	su.query();
	if (su.next()) {
		company = su.company.toString();
		foundComp = true;
	}

	//Get the users where current company matches
	var compUsers = [];
	if (foundComp) {
		var suc = new GlideRecord('sys_user');
		suc.addQuery('company', company);
		suc.query();
		while (suc.next()) {
			compUsers.push(suc.getValue('sys_id'));
		}
	}
	return compUsers;
}

Seems to work for any field that is a reference to sys_user.