- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 07:14 AM - edited 06-27-2026 07:23 AM
Hi Team,
I am working with the Data Table from Instance Definition widget in Service Portal.
In the Widget Instance configuration, I am trying to use a Script Include in the Filter field, as shown in the screenshot below.
Example:
Store is one of javascript:new global.MyHeroLetters().getStoresForCurrentUser();However, the Script Include is never executed. I added gs.log() statements inside the method, but no logs are generated, indicating that the Script Include is not being invoked.
The Script Include is active and accessible, and the method returns a comma-separated list of sys_ids.
Could anyone clarify:
- Does the Filter field of the Data Table from Instance Definition widget support javascript: expressions?
- If not, what is the recommended approach for applying a dynamic filter based on the current user?
Script Include is as follows:
Any guidance would be appreciated.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 07:54 PM
hi @Sachin Gavhane ,
Modify the widget's Server Script.
var stores = new global.MyHeroLetters().getStoresForCurrentUser();
data.filter = "storeIN" + stores;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2026 01:40 AM
yes @Sachin Gavhane ,
So you can clone & customize the widget :
Clone the Data Table from Instance Definition widget and modify the Server Script to dynamically build the encoded query before passing it to the data table.
// In the cloned widget's Server Script
var stores = new global.MyHeroLetters().getStoresForCurrentUser();
data.filter = "store.sys_idIN" + stores;
// Then pass data.filter into your GlideRecord query
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 07:53 AM
Can you confirm whether your cloned/custom widget is triggering properly.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 11:12 AM
yes, widget is triggering properly @Tanushree Maiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 08:14 AM
Hello @Sachin Gavhane ,
can you confirm that the filter field can call script Includes ?
Because as far as I know the javascript: expressions in that filter field only work with client accessible objects like g_user.userID, g_user.name, etc. They cannot call Script Includes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2026 11:16 AM
Neither I am sure whether filter can call script include @yashkamde
Kindly help me with other approach incase if SI is not possible here in the filter
Thanks !