Use Script Include in Condition Filter or Reports

Author: Rohan Aditya – breaking Condition Builder limits.

Key points covered:

  • Using scripting to enhance report filters
  • Bypassing limitations of Condition Builder

Before You Begin

Role required: admin

Steps

  • Go to System Definition > Script Includes
  • Click New
  • Fill out the form: Name as ReportsAJAX and check Sandbox
  • Ensure the Script Include name and method name match
  • Paste the following script that returns Active P1 incidents:
function ReportsAJAX() {
  var incGr = new GlideRecord('incident');
  incGr.addActiveQuery();
  incGr.addQuery('priority', '1');
  incGr.query();
  var incidentArray = [];
  while (incGr.next()) {
    incidentArray.push(incGr.sys_id.toString());
  }
  return incidentArray;
}

🚨 If Sandbox isn’t checked, your script won't work and you’ll start questioning every life choice that led to this moment.

How to Use It in a Filter

When you're filtering incidents, do this:

SYS ID → is one of → javascript:ReportsAJAX();
Condition Builder filter

And boom — the Condition Builder starts behaving like it understands what you want. ✨

How to Use It in a Report

In the report Condition, add this:

SYS ID → is one of → javascript:ReportsAJAX();
Report Condition filter