How to Create Your Own Dynamic Filter Option in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
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
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
- 351 Views
