Skip to content

Commit dc8c5f3

Browse files
authored
Create Bucket Group Age Calculation.js
1 parent 002bc1e commit dc8c5f3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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
3+
rec.query();
4+
while (rec.next()) {
5+
var openedDate = new GlideDateTime(rec.opened_at.getDisplayValue());
6+
var dur = GlideDateTime.subtract(openedDate,actualDateTime );
7+
//gs.info("dur"+dur.getNumericValue()) ;
8+
elapsedTime = dur.getNumericValue()/86400000 ;
9+
// gs.info ("elapsedTime" + elapsedTime)
10+
// Check to see when the item was created
11+
if (elapsedTime <= 2) aging = '0-2 Days';
12+
if (elapsedTime > 2) aging = '3-4 Days';
13+
if (elapsedTime > 4) aging = '5-7 Days';
14+
if (elapsedTime > 7) aging = '8-15 Days';
15+
if (elapsedTime > 15) aging = '16-30 Days';
16+
if (elapsedTime > 30) aging = '31-60 Days';
17+
if (elapsedTime > 60) aging = '61-90 Days';
18+
if (elapsedTime > 90) aging = 'Over 90 Days';
19+
20+
rec.setWorkflow(false); // Skip any Business Rules
21+
rec.autoSysFields(false); // Do not update system fields
22+
rec.aging_category = aging;
23+
rec.update();
24+
}

0 commit comments

Comments
 (0)