dynamic filter on the incident table

Alon Grod
Tera Expert

Hi,

Im trying to create a dynamic filter when choosing the caller field on the incident table.
I want to show all incidents that created from callers that share department like the login user, but i had no luck.

Screenshot 2024-07-08 at 18.23.25.png

Screenshot 2024-07-08 at 18.24.11.png



This is before using the filter:

Screenshot 2024-07-08 at 18.24.41.png



After using the filter(for some reason Im only getting incident that created by Abel but Dolev is also from my department):

Screenshot 2024-07-08 at 18.25.31.png

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Alon Grod Are you sure, if you are using the dynamic filter correctly. Here is how I created a dynamic filter to show the incidents from the user who are from my department.

 

Screenshot 2024-07-08 at 9.36.42 PM.png

Screenshot 2024-07-08 at 9.37.11 PM.pngScreenshot 2024-07-08 at 9.37.42 PM.png

Here is the script include code.

 

var GetUsersFromDepartment = Class.create();
GetUsersFromDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getMyDepartmentUsers:function() {
        var userArray = [];
        var glideUser = new GlideRecord('sys_user');
        glideUser.addActiveQuery();
        glideUser.addQuery('department', gs.getUser().getDepartmentID());
        glideUser.query();
        while (glideUser.next()) {
            userArray.push(glideUser.getValue('sys_id'));
        }
        return userArray;
    },
    type: 'GetUsersFromDepartment'
});

 

Here is how I am calling this script include from the script field of the dynamic filter.

new global.GetUsersFromDepartment().getMyDepartmentUsers();

 

Here is how the dynamic filter should be applied on the incident list.

 

Screenshot 2024-07-08 at 9.41.55 PM.png

 Hope this helps

View solution in original post

5 REPLIES 5

Saloni Suthar
Mega Sage
Mega Sage

Could you let me know if you are trying to filter the incidents where the department is currently logged in's department? 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Kieran Anson
Kilo Patron

If I've understood your requirement, you shouldn't need a complex script. The following should be sufficient

Screenshot 2024-07-08 at 17.08.36.png

 

Then within the query builder

 

Screenshot 2024-07-08 at 17.09.24.png

@Kieran Anson i did exactly like you and this is what im getting.

Before filter:

Screenshot 2024-07-08 at 19.48.29.png



After:

 

Screenshot 2024-07-08 at 19.48.54.png

 

Please make sure the current logged in user has department on the user record.


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni