Question about JAVAscript in Reports

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 02:59 PM
I recently started a job, the previous person already left. I am reviewing a Report previously built. I am very familiar with Reports, however I am unclear on this.
Table: alm_asset
These two Conditions were added:
(1) Configuration Item.Reporting class is one of javascript: new SmbcEOLUtils().getSFTClasses()
(2) Configuration Item.Company.Sys ID is one of javascript:global.getGroupCompaniesForRegion("AD-CUSO");
Can someone help what these are filtering or doing for the report? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 03:12 PM - edited 03-06-2024 03:13 PM
Hi @Marc Schlank1 ,
In the report filter condition, "javascript:" used for adding dynamic parameter based on supplied function.
In first case, there should be script include with name "SmbcEOLUtils" contains the method "getSFTClasses", so return of this method "getSFTClasses" is report filter parameter at run time.
Similarly for second case also, the script include with name "getGroupCompaniesForRegion", taking the region "AD-CUSO" as parameter and return input for report as run time.
- you can review both the script include to get know more about these two dynamic method.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 03:24 PM
Where do I find the Scripts in ServiceNow...for the report to apply?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 03:23 PM
Hi @Marc Schlank1 ,
Those are scripted filters, Certain filters, like presenting a record set that depends on an unrelated table, cannot be created by the condition builder alone. You can write JavaScript functions for usage in advanced filters
Locate the script include by going to System Definition > Script Includes; for instance, for filter javascript: new SmbcEOLUtils().getSFTClasses(), The name of the script include is SmbcEOLUtils() and getSFTClasses() is a function in the script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 03:27 PM
Hi @Marc Schlank1 ,
Please refer below article:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0746219
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda