Not able to call the script include in the arguments from "All" module in incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2026 10:34 PM - edited 03-10-2026 10:34 PM
Hi Everyone,
I have created a Script Include, and with this Script Include I want to retrieve incidents that meet the following conditions:
Incidents opened by me
Incidents where the caller_id is me
Incidents where I am part of the assignment group
I do not want to use filter conditions in the module because I am testing a scenario where I need to pull data from different places. Therefore, I want to use a Script Include and call it in the "All" module related to Incident through the Arguments field.
When I test the Script Include in Scripts - Background, it returns the expected values. However, when I click on the All module, it does not return the results.
I tried calling the Script Include using the following approaches in the module arguments:
sysparm_query=javascript:new IncidentVisibilityUtil().getMyIncidents()javascript:new IncidentVisibilityUtil().getMyIncidents()
But neither of these worked.
Could you please help me understand the correct way to call this Script Include from the module arguments? Also, please let me know if I am missing anything in my configuration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi prasannasun,
Your Script Include is fine — since it returns the expected query string in Background Scripts, the problem is in how the module passes it. Two things are working against you:
1. The OOTB "All" module is a "List of Records" module. Modules of that type build their URL from the Table + Filter fields; the Arguments field is not where a javascript: query gets evaluated, so what you type there never becomes an evaluated sysparm_query. Editing the OOTB module's Arguments therefore has no effect.
2. Your second attempt (the javascript: call on its own as the whole Arguments value) is not a URL at all — Arguments for this pattern must contain the full list URL including sysparm_query=.
What works:
- Don't modify the OOTB module. Create your own module under the Incident application menu (or copy All and change the copy), and set:
- Link type: URL (from Arguments:)
- Arguments: incident_list.do?sysparm_query=javascript:new IncidentVisibilityUtil().getMyIncidents()
- With the "URL (from Arguments:)" link type, the Arguments value is used as the link URL, and when the list loads, the platform evaluates the javascript: expression in sysparm_query server-side (as the currently logged-in user, so gs.getUserID() resolves per user — exactly what your use case needs) and applies the returned encoded query: opened_by=<user>^ORcaller_id=<user>^ORassignment_groupIN<group sys_ids>. Your function's return format (including the IN list) is already a valid sysparm_query value.
Two checks if it still returns nothing after switching the link type:
- Scope/accessibility: if IncidentVisibilityUtil lives in a scoped application, set the Script Include's "Accessible from" to "All application scopes" (or create it in Global). A scope-restricted Script Include fails silently in this context, while Background Scripts in the same scope runs fine — which matches your symptom exactly.
- It does NOT need to be "Client callable" — that flag is only for GlideAjax. This evaluation is server-side.
One design note: because this is evaluated on every click for every user, keep the function cheap (your single sys_user_grmember query is fine). And since you said you specifically don't want module filter conditions, this URL-from-arguments pattern is the supported way to get a dynamic per-user filter on a module.
Hope that resolves it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi,
I hope this has already been resolved however just in case, you can use query parameter like below and client callable must be set as true for your script include.
sysparm_query=javascript:new IncidentVisibilityUtil().getMyIncidents();
Thanks