Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var rec = new GlideRecord('case'); // any table which you want to use
rec.addEncodedQuery('stateNOT IN60,40, 20'); // filtering out all the closed/cancelled cases 60 is closed, 40 is cancelled, 20 is rejected
rec.query();
while (rec.next()) {
var openedDate = new GlideDateTime(rec.opened_at.getDisplayValue());
var dur = GlideDateTime.subtract(openedDate,actualDateTime );
var elapsedTime = dur.getNumericValue()/86400000 ;
// Check to see when the item was created
var aging;
if (elapsedTime <= 2) aging = '0-2 Days';
if (elapsedTime > 2) aging = '3-4 Days';
if (elapsedTime > 4) aging = '5-7 Days';
if (elapsedTime > 7) aging = '8-15 Days';
if (elapsedTime > 15) aging = '16-30 Days';
if (elapsedTime > 30) aging = '31-60 Days';
if (elapsedTime > 60) aging = '61-90 Days';
if (elapsedTime > 90) aging = 'Over 90 Days';

rec.setWorkflow(false); // Skip any Business Rules
rec.autoSysFields(false); // Do not update system fields
rec.aging_category = aging; // updating aging category with defined buckets allocated above
rec.update();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Find out all the cases with the difference in their create date and current date and put them in different buckets of their age. Then you can report on the aging. With this you will be able to run the Bucket Group reporting on tables without using PA.

In ServiceNow Performance Analytics (PA), a Bucket Group is used to categorize or group data into defined ranges or segments, which helps make reports and indicators more meaningful and easier to analyze. This code will help you to categorize the tickets based on any defined ranges or segments you want. Based on this defined ranges or segments you can get any king of reporting without using PAs in ServiceNow.

This code lets you create custom ranges (buckets) to classify numerical data (like durations, scores, or counts) into meaningful labels.For example, instead of showing raw numbers like 2, 7, 14, 30 days, you can define buckets such as:

0–5 days → “Very Fast”

6–10 days → “Fast”

11–20 days → “Average”

>20 days → “Slow”

Then, these labels can be displayed in your dashboards, or reports, making the data easier to interpret.

Real time user cases:

1. Score or metric segmentation
Divide customer satisfaction scores into Low, Medium, High ranges.

2. Priority or risk scoring
Convert numeric risk scores into descriptive ranges (Low Risk, Medium Risk, High Risk).

Also, SLA uses the tickets to be defined in SLA number or breach date. It doesnt let you define any segment or categorize the data. It helps you define the reporting basis on your category or segment
Loading