Two report needs to be built one for the requests raised by IT user and other is Non-IT user.

karishmanat
Tera Contributor

I have created two dynamic filters in ServiceNow:

  1. Member of IT Groups
  2. Not Member of IT Groups

In my instance, I have two IT groups:

  • Service Desk
  • Network

For example, Fred Luddy is a member of the Network group, so he is considered an IT user.

My requirement is:  If a user like Fred Luddy (who belongs to an IT group) raises/creates an RITM, that record should appear in the report.

To achieve this, I created a dynamic filter and used it in the report condition. However, even after configuring everything and trying multiple approaches, the report is still not showing the expected records.

I have also attached screenshots of my configuration.

 I need help understanding where the mistake is and why the records are not appearing, even though the user belongs to the IT group.

karishmanat_0-1782211305503.pngkarishmanat_1-1782211336302.pngkarishmanat_2-1782211360506.pngkarishmanat_3-1782211445012.png

 

 

4 REPLIES 4

Mariam_Ahmed
Tera Guru

 

Hi @karishmanat ,

I think the issue is with how the dynamic filter is configured. Before building a custom solution, I'd also recommend checking whether an out-of-the-box (OOTB) dynamic filter can satisfy your requirement.

If you need to proceed with a custom dynamic filter, update your Script Include to return an array of user  for example:

getGroupMembers: function() {
    var userList = [];
    var group1 = 'YOUR_GROUP_SYS_ID';
    var group2 = 'YOUR_GROUP_SYS_ID';

    var gr = new GlideRecord('sys_user_grmember');
    gr.addEncodedQuery('group=' + group1+ '^ORgroup=' + group2); 
    gr.query();

    while (gr.next()) {
        userList.push(gr.getValue('user'));
    }

    return userList; // Returns an array of user Sys IDs
},

type: 'GroupFilterUtil'

2. Configure the Dynamic Filter Option

Navigate to System Definition > Dynamic Filter Options and create a new record with the following values:

  • Label: IT Members

  • Script: new GroupFilterUtil().getGroupMembers();

  • Field type: Reference

  • Reference table: sys_user (since opened_by is a reference to the User table)

  • Available for filter: Checked

Save the record.

3. Apply the filter in the report

In the report condition builder, configure:

Opened by >is (dynamic) > IT Members

If you found this response useful, please mark it as Helpful and accept it as the Solution to help others with similar questions.


Best regards,

Mariam Ahmed.

I have created everything as per your instructions, but I am still not able to fetch any records in the report. I will attach the screenshot for your reference.
karishmanat_0-1782231443520.pngkarishmanat_1-1782231491318.pngkarishmanat_2-1782231515976.png

 

Hi @karishmanat,

Add the following to the Dynamic Filter script:

 
new global.GroupFilterUtil().getGroupMembers()

Also, ensure that:

  • The Script Include is marked as Client Callable.
  • Sandbox is enabled for the Dynamic Filter.

 

Mariam_Ahmed_0-1782235885689.png

 

Expected Result: The dynamic filter should return the group members from the GroupFilterUtil Script Include and populate the filter correctly.

Mariam_Ahmed_1-1782235997548.png

 

If you found this response useful, please mark it as Helpful and accept it as the Solution to help others with similar questions.


Best regards,

Mariam Ahmed.

 

Tanushree Maiti
Tera Patron

Hi @karishmanat 

 

For this use case , easiest option would be create a Database view.

 

  • Navigate to System Definition > Database Views.
  • Create a new view (like u_ritm_it_user).
  • Add the Requested Item [sc_req_item] table (Prefix: ritm)
  • and the Group Member [sys_user_grmember] table (Prefix: gm).
  • Add the Where clause: ritm.opened_by = gm.user
  • Create your report on this new Database View and set the condition: Group is [Network]

 

Regarding Dynamic filter- Refer

KB0746219 Creating dynamic JavaScript filters in reports 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti