How to Create Your Own Dynamic Filter Option in ServiceNow

Tejas Adhalrao
Tera Guru

4078_TA_0-1768625007041.png

Dynamic Filter Options allow you to use JavaScript logic in filters instead of hard-coded values. This is very useful when filter results should change based on the logged-in user or business logic.

 

step 1)Create a Script Include that returns an array /string

4078_TA_1-1768625025007.png

Important: Enable Sandbox Enabled

 This is mandatory.

I personally wasted a full day because the filter was not working.
After enabling Sandbox Enabled, it started working correctly.

Why Sandbox Enabled is Required?

When ServiceNow runs JavaScript from Dynamic Filters, it is not normal server-side code.

  • The script is triggered from the UI / client side

  • For security reasons, ServiceNow runs it inside a sandbox

  • The sandbox allows read-only access and blocks unsafe operations

That’s why:

  • Your Script Include must be Sandbox Enabled

  • Otherwise, the dynamic filter will not execute

 

Step 2: Create Dynamic Filter Option

 

System Definition → Dynamic Filter Options -> new

4078_TA_3-1768625184438.png

 

 Label =This is the display name shown in the filter dropdown.

Script = call you script include

Field type =Type of value returned by script.

Referenced table : filter will apply on this table fields

 

 

 

 

thanks

tejas

0 REPLIES 0