We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Script Include not getting executed in "Data Table from Instance Definition" widget instance filter

Sachin Gavhane
Tera Guru

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.

SachinGavhane_1-1782569665671.png

 

 

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:
    SachinGavhane_0-1782570204319.png

     

Any guidance would be appreciated.

Thank you!

 

 

 

 

2 ACCEPTED SOLUTIONS

Tejas Adhalrao
Kilo Sage

hi @Sachin Gavhane  ,

Modify the widget's Server Script.

 

var stores = new global.MyHeroLetters().getStoresForCurrentUser();

data.filter = "storeIN" + stores;

View solution in original post

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.

View solution in original post

7 REPLIES 7

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.

Tejas Adhalrao
Kilo Sage

hi @Sachin Gavhane  ,

Modify the widget's Server Script.

 

var stores = new global.MyHeroLetters().getStoresForCurrentUser();

data.filter = "storeIN" + stores;

Sachin Gavhane
Tera Guru

below code worked in the ServerSide script of the widget.

Thanks @yashkamde  @Tejas Adhalrao @Tanushree Maiti  for your help

SachinGavhane_0-1782716094719.png