Skip to content

Commit 7639951

Browse files
authored
Categorize the data in different category or segment which helps in ServiceNow Reporting (#1899)
* Create readme.md * Create Bucket Group Age Calculation.js * Delete Server-Side Components/Scheduled Jobs/readme.md * Create readme.md * Update Bucket Group Age Calculation.js adding the line 2 state values and defining variables and removing the log statements * Update readme.md
1 parent 1241a41 commit 7639951

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var rec = new GlideRecord('case'); // any table which you want to use
2+
rec.addEncodedQuery('stateNOT IN60,40, 20'); // filtering out all the closed/cancelled cases 60 is closed, 40 is cancelled, 20 is rejected
3+
rec.query();
4+
while (rec.next()) {
5+
var openedDate = new GlideDateTime(rec.opened_at.getDisplayValue());
6+
var dur = GlideDateTime.subtract(openedDate,actualDateTime );
7+
var elapsedTime = dur.getNumericValue()/86400000 ;
8+
// Check to see when the item was created
9+
var aging;
10+
if (elapsedTime <= 2) aging = '0-2 Days';
11+
if (elapsedTime > 2) aging = '3-4 Days';
12+
if (elapsedTime > 4) aging = '5-7 Days';
13+
if (elapsedTime > 7) aging = '8-15 Days';
14+
if (elapsedTime > 15) aging = '16-30 Days';
15+
if (elapsedTime > 30) aging = '31-60 Days';
16+
if (elapsedTime > 60) aging = '61-90 Days';
17+
if (elapsedTime > 90) aging = 'Over 90 Days';
18+
19+
rec.setWorkflow(false); // Skip any Business Rules
20+
rec.autoSysFields(false); // Do not update system fields
21+
rec.aging_category = aging; // updating aging category with defined buckets allocated above
22+
rec.update();
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
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.
2+
3+
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.
4+
5+
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:
6+
7+
0–5 days → “Very Fast”
8+
9+
6–10 days → “Fast”
10+
11+
11–20 days → “Average”
12+
13+
>20 days → “Slow”
14+
15+
Then, these labels can be displayed in your dashboards, or reports, making the data easier to interpret.
16+
17+
Real time user cases:
18+
19+
1. Score or metric segmentation
20+
Divide customer satisfaction scores into Low, Medium, High ranges.
21+
22+
2. Priority or risk scoring
23+
Convert numeric risk scores into descriptive ranges (Low Risk, Medium Risk, High Risk).
24+
25+
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

0 commit comments

Comments
 (0)