create a list view module that match the tickets with logged-in user company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 11:25 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 02:11 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 05:39 PM
You can create a Dynamic Filter Option like:
and define a script include:
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.