Aging reports on Incident

SNOW46
Tera Contributor

Hi All,

I want to schedule an Aging Report on Incident in which it will display in tabular format like in Pivot Table format.

Can anyone share me some ideas as well as help on the same so that I will configure and implement the same as well.

 

find_real_file.png

 

Like the same as above image.

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

Here's what you'll need to do...

1)  Create a new 'Choice' field on the 'incident' table named 'Aging category'

2)  Right-click that field label from your form and select 'Configure choices' to add the following choices.  COPY THESE VALUES EXACTLY!

3-7 Days

8-14 Days

15-21 Days

22-28 Days

> 28 Days

3)  Navigate to 'System Definition -> Scheduled Jobs' and select 'Automatically run a script of your choosing'.  Here you'll create a scheduled job to run a script to get you accurate counts for your report.  You can run this as often as you want, but I'd probably only run it every day or so you don't negatively impact your instance performance.  You should use this in the 'Script' field.

u_updateIncidentAging();

function u_updateIncidentAging() {
	var elapsedTime = 0;
	var aging = '';
	var currentTimeNow = gs.nowDateTime();
	var gr = new GlideRecord('incident');
	gr.addEncodedQuery('u_aging_category!=>28^ORu_aging_category=');
	gr.query();
	while(gr.next()) {
		elapsedTime = (gs.dateDiff(gr.opened_at, currentTimeNow, true))/60/60/24;
		
		// Check to see when the item was created
		if (elapsedTime <= 2) aging = '0-2 Days';
			if (elapsedTime > 2)  aging = '3-7 Days';
			if (elapsedTime > 7)  aging = '8-14 Days';
			if (elapsedTime > 14) aging = '15-21 Days';
			if (elapsedTime > 21) aging = '22-28 Days';
			if (elapsedTime > 28) aging = '> 28 Days';
			
		gr.setWorkflow(false); // Skip any Business Rules
		gr.autoSysFields(false); // Do not update system fields
		gr.u_aging_category = aging;
		gr.update();
	}
}

Your scheduled job should look like this...

find_real_file.png

Once this is in place, you can click the 'Execute now' button to run the script and populate your new field.  You should be able to go to any incident record and see this value populated correctly.

4)  Create your report.  The report should look like this...

find_real_file.png

View solution in original post

29 REPLIES 29

Hi Mark,

Did you got any chance to look into my query as I need to address it to my Management with the report.

But before that I need your help to get it rectified if I am wrong any where?

 Its an request to you to please look into it and let me know.

 

 

Thanks,

SNOW@Das

The only difference I see is that your choice field values are different from the labels.  In my setup they are identical.  Maybe you could try changing the value for the 15-21 option (and then update one of the corresponding records) and see if that makes a difference?

Hi Mark,

As suggested I have made the changes as below.

 

find_real_file.png

 

And the report is as below.

 

find_real_file.png

But I found some records as below.

find_real_file.png

How come it is calculating the no of days as it is also including Sat and Sunday as well. It was opened on 6th Feb,2019 and comes under category 15-21.

For the below Records, it was opened yesterday is it coming under correct category as 0-2 Days.

find_real_file.png

Please help me in my queries if it is all perfect and good to go?

 

Thanks,

SNOW@Das

 

February 6 would be 21 days, right?  You've also got time zones, etc. to account for but it looks like that's in the correct aging category.  Check it again in a day and it should be in the 22-28 days category, right?  I think it's working great now that you've corrected the values.

Hi Mark,

One of our user has reported that the Aging Bucket is not working as expected.

Its taking greater than 5 days tickets under 0-5 days bucket and even though there are tickets greater than 30 days but it is not displaying any tickets under this bucket.

Also there are few incidents which are of ageing greater than 10 days but shows under 0-5 days Ageing category.

Can you please suggest me how to fix this immediately?

 

Thanks in Advance..