- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 09:01 AM
Hi.
I need to apply a fixed (preferrably) query to a module that displays a list of records in a scoped application.
Is it possible use a script include to build the query of a module?
I've seen on the instance some OOTB cases in which this was done with a module of type List of record with a script include call in the arguments but I haven't been able to do it myself.
Has someone done this before or is there another solution?
I could do this with a before query business rule but I would rather not.
This is the code in the script include to build the query.
getCurrentUserGroups: function() {
var groups = [];
var grGroupMember = new GlideRecord("sys_user_grmember");
grGroupMember.addEncodedQuery("user=" + gs.getUserID() + "^group.nameSTARTSWITHmy group prefix");
grGroupMember.query();
while (grGroupMember.next()) {
groups.push(grGroupMember.group());
}
return groups.toString();
},
filterForGroups: function() {
var groups = this.getCurrentUserGroups();
return "assignment_groupIN" + groups;
},
I know there is a Dynamic filter for the user's groups but that adds every group to the query not only the application ones.
In the module I have tried to invoke this script inlcude with every kind of syntax but I wasn't able to execute it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2024 05:48 AM
After checking the "Snadbox enabled" checkbox on my client callable script include record I was able to succesfully use it in the module.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 09:35 AM
In the filter for the module, did you try to select Assignment Group IS ONE OF and then do something like this?
javascript: getCurrentUserGroups();
You would need to change your script to just include the list of sys_ids, but it might work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 11:22 AM
I'm sure there's a way to get this to work with the correct argument, or maybe a new dynamic filter, but it seems like a simple filter might work in this case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 01:28 AM
In the end I just used a before query business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 04:09 AM
If you don't want that to apply everywhere, you could create a Database View with just the one table, then use the Database View as the table for the before query Business Rule and module.