How can I create a scripted filters on user table.

Chandra18
Mega Sage

Hello experts,

I want to create a scripted filters on user table for showing user which having the "Itil" role.
I have taken the help from https://docs.servicenow.com/bundle/washingtondc-platform-user-interface/page/use/using-lists/task/t_...

I created below script include:

Chandra18_0-1713435829869.png


Please help on that.

Thank You!


1 ACCEPTED SOLUTION

Hi @Chandra18 ,

 

Please Remove all the content of the script and just keep below script or your script will also work 

 

function myFunction(){
        var arrUsers = [];
        gr = new GlideRecord('sys_user_has_role');
        gr.query('role', '282bf1fac6112285017366cb5f867469');//itil role sys_id
        while (gr.next()) {
            arrUsers.push(gr.user.toString());
        }
        return arrUsers;


}

 

 

AstikThombare_0-1713441123757.png

 

 

AstikThombare_1-1713441123800.png

 

 

 

    If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                         By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

 

Astik

 

View solution in original post

6 REPLIES 6

Astik Thombare
Tera Sage

Hi @Chandra18 ,

 

Could you please elaborate more on what you're trying to do and what issue you're facing?

 

 

Thanks,

Astik

 

 

 

Hi @Astik Thombare 

I want to achieve as below attached video but my condition is "user which having the "Itil" role on user table."

https://youtu.be/rcwq6pvN-kE?si=q9bf_TZKF8ySH50z

 

In @servicenow we can create reports and apply conditions using conditional breadcrumb but we can't apply advance conditions using breadcrumb, For that we must write down script using script include and call that in filter conditions. In this tutorial I have explained how we can create and call ...

Hi @Chandra18 ,

 

Please Remove all the content of the script and just keep below script or your script will also work 

 

function myFunction(){
        var arrUsers = [];
        gr = new GlideRecord('sys_user_has_role');
        gr.query('role', '282bf1fac6112285017366cb5f867469');//itil role sys_id
        while (gr.next()) {
            arrUsers.push(gr.user.toString());
        }
        return arrUsers;


}

 

 

AstikThombare_0-1713441123757.png

 

 

AstikThombare_1-1713441123800.png

 

 

 

    If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                         By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

 

Astik

 

Hi @Astik Thombare 

Please provide below line again, give role by properties without hardcoded.
 

gr.query('role', '282bf1fac6112285017366cb5f867469');