- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 12:45 AM
I want to add a condition using a script to Search Sources of AI Search.
If you know how to add it, please let me know.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 10:28 AM
Hi @Yudai Yamamoto!
Currently it is not possible using scripts to perform filters in Search Source , see:
âž” ServiceNow Docs - Search sources
Alternatively, you can work with ACLs, if the user does not have permission to see a record due to security permissions, it will automatically not appear in the AI ​​Search results.
If my answer helped you in any way, please mark it as Helpful / Accept as Solution 🎯
Regards,
Isaac Vicentini.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 10:28 AM
Hi @Yudai Yamamoto!
Currently it is not possible using scripts to perform filters in Search Source , see:
âž” ServiceNow Docs - Search sources
Alternatively, you can work with ACLs, if the user does not have permission to see a record due to security permissions, it will automatically not appear in the AI ​​Search results.
If my answer helped you in any way, please mark it as Helpful / Accept as Solution 🎯
Regards,
Isaac Vicentini.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 10:40 AM
To add a condition using a script for AI Search, you’d typically need to identify the parameters or criteria you want to filter by—like keywords or source types—and implement logic in your script to ensure the search only pulls from relevant sources. For example, if you're searching for 'AI Search' sources related to a specific topic, you'd apply a condition to filter based on that. Speaking of targeted searches, if you're looking for the best Chinese restaurants in Edmonton, you could add a condition to your search to focus on restaurant reviews or specific ratings, helping you narrow down the top spots like The Lingnan or Dynasty Century Palace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2025 07:06 AM
I was looking for something like this as well since I need the AI to suggest Knowledge Articles based on the Contact domain.
Dont think this works well for domain separated instances...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hi Yudai,
it is possible to use inline scripts in search source filters.
Create a script include and check your required condition within.
To use it in the search source filter you need to use some string field of your source table.
For example for business applications you could use the "Portfolio ID" field.
The Portfolio ID of an application is something like APP1234567
Search Source:
Condition: Portfolio ID starts with APP
Condition with Script: Portfolio ID starts with javascript:new scope.Your_Script_Include.your_function('allowTerm', 'denyTerm')
>> Portfolio ID starts with javascript:new global.ZTAValidation.roleCheck('APP', 'forbidden')
Provide the function the values for a allowTerm and a denyTerm. If your script validates to "true" return "APP" as allowTerm. The filter will validate as true and deliver results.
Should the script return "false" return "forbidden" as denyTerm. No results will be shown while searching.
You can use any free text field to use the inlince script validation. This will also work for external content.
Hope this helps.