Creating a Dynamic Filter

Shir Sharvit
Tera Contributor

Hey

I created another filter option for dynamic "My Department".

the field "department" is reference field to 'cmn_department'


script include:

ShirSharvit_0-1720437648313.png

The code:

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


        getDepartment:function(user){
        var gr = new GlideRecord('sys_user');
        gr.addQuery('sys_id' , user);
        gr.query();

        gs.log('Shir');


        var department;

        if(gr.next()){
                department = gr.department;
               
        }
        return department;

        },
       



    type: 'MyDepartment'
});

 

Dynamic Filter Options

ShirSharvit_1-1720437675665.png

 

It doesn't work, I would appreciate some help

The filter is shown,
but does not actually filter the list by department

ShirSharvit_2-1720437752401.png

 

2 REPLIES 2

LJ86
Kilo Guru

Hi Shir,

 

You need Caller's Department in the filter rather than Caller itself.

 

To achieve this, enable "dot-walking" in the filter:

 

LukaszJ_0-1720443644789.png

Then:

LukaszJ_1-1720443718774.png

And finally:

LukaszJ_2-1720443774348.png

Hope this helps!

Lukasz

T_Prashaanth
Mega Guru

HI @Shir Sharvit , in the dynamic filter , set the reference table to Deparment (cmn_department).

And in the list filter - give the filter condition as Caller -> Department is dynamic -> My Deparment.

 

T_Prashaanth_0-1720478342994.png

 

T_Prashaanth_1-1720478397374.png

 

Please , mark the answer as Correct/Helpful , if this is useful.