Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to call a script include / server script through reports? - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to call a script include / server script through reports?
KB0832058

How to call a script include / server script through reports?


20208 Views Last updated : Sep 26, 2022 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Summary

This article describes using reports to call a script include.

JavaScript that runs on the server is stored in script includes. You can include an existing script from a script or even a report.

Typically, reports are used to pull data based on existing or current values. The reporting requirement may become complex at times, and we may be unable to use the conditions to obtain the desired results.

You might need to use a script include to get the result (dynamic records).

Instructions

  1. Use the sys_id column to get dynamic records. In report have the following condition,
    sys_id is javascript:new ReportUtils().getRecords() 
    where "ReportUtils" is the script include name and getRecords is the function name in the script include.

  2. You can even go through the below KB's for few examples:
    • Create a report on users having multiple assets
    • Report on alm_asset table with users having more than 1 asset
  3.  Create a business rule and call the function defined in the business rule.

    For example, refer the OOB business rule "getMyApprovals". It has a function "getMyApprovals".
    You can call this script using the below syntax:
    Approver is javascript:getMyApprovals()

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.