---
sourceDocument: Australia ServiceNow AI Platform user interface
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/platform-user-interface

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia ServiceNow AI Platform user interface

ft:clusterId :

    - platux

bundleId :

    - platux

workflow :

    - Platform


---

# Create scripted filters

# Create scripted filters {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The condition builder alone cannot create some filters, such as displaying a record
set that depends on an unrelated table. If you know JavaScript, you can create JavaScript
functions for use in advanced filters.

## Before you begin

Role required: admin

## Procedure

1. Create a new script include.
   1. Navigate to AllSystem DefinitionScript Includes.
   2. Click New.
   3. Fill out the form, and then select Submit.
   {#t_ScriptedFilters__substeps_avv_2rf_yfb}
2. Open the script include and, in the Script field, create a JavaScript function that returns an array of `sys_ids`.  
   * Ensure that the function uses the same name as the script include.
   * Ensure that the script include is Active and Client callable.
   {#t_ScriptedFilters__ul_ulc_4sk_gp}
3. Call the JavaScript function from the condition builder.  
   For more information, see [GlideRecord](https://www.servicenow.com/docs/access?context=p_GlideServerAPIs&version=australia&pubname=australia-api-reference&section=c_GlideRecord&ft:locale=en-US) queries and [Script includes](https://www.servicenow.com/docs/access?context=c_ScriptIncludes&version=australia&pubname=australia-api-reference&ft:locale=en-US).  
   Note:  
   Grouped lists with a script include in the filter may cause slowness.

## Example

A company provides intensive care for a group of customers. To track these services, the service manager needs a high-level journal and links to all incidents that the customers raise.

The company creates an application, Intensive Care, and a table,
\[u_intensive_care\]. While the table contains a reference field for the customer
name, there is no direct link to the user table. Thus, the manager cannot set up an
incident list filter using the condition builder for customers who are under
intensive care.  
The solution is to write a JavaScript function that uses a GlideRecord query to build an array of user sys_ids in the \[u_intensive_care\] table, as shown in the sample code below. Call the function from the condition builder in the Incident table (\[Caller\] \[is\] \[javascript:myFunction()\]).

    function myFunction(){ 
        var arrUsers = [];
        var gr = new GlideRecord('u_intensive_care');
        gr.query(); 
        while(gr.next()){
            arrUsers.push(gr.u_customer.toString()); 
        }
        return arrUsers;
    }

**Related tasks**   

* [Create and edit filters](https://servicenow-prod.fluidtopics.net/mIPl4~wh84X0eEsDHHAJCA "Set up and edit an admin-configured filter.")
* [Delete filters](https://servicenow-prod.fluidtopics.net/adoJ1jnuiyEGaX9Og6kRkQ "You can delete any saved filter, including global, group, or personal filters.")
* [Create a dynamic filter option](https://servicenow-prod.fluidtopics.net/yFXRWCI9nXWA8cALcdwYSQ "Dynamic filter options enhance filtering by allowing users to run existing script includes or JavaScript against a reference field within condition builders and dynamic reference qualifiers.")

*[\>]: and then


