- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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
3 weeks ago
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
3 weeks ago
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
3 weeks ago
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
3 weeks ago
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
3 weeks ago
below code worked in the ServerSide script of the widget.
Thanks @yashkamde @Tejas Adhalrao @Tanushree Maiti for your help