- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 06:00 PM
I would like to calculate the amount of time between when the user opens a ticket and when that ticket is closed. The state it is set to when created is Opened and the state when it is closed, you guessed it, it's Closed. So I am in need in getting the amount of time the ticket was open....
Example: ticket was opened at 8:00 AM closed at 9:00 AM. So the field would need to read 1 hour.... I have seen the duration field, how can i calculate this in that field?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 07:02 PM
I would instead recommend using METRICS as that is their point. TO measure that kind of stuff.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 07:00 PM
I don't think having a field for that calculation is the best use of a field but if you must here's what you would need to do.
To get that duration you would need to know when it was opened. That is currently stored in incident.sys_created_on.
With that information, you can then add a before business rule to run when the state.changesTo('numberforclosedstate');
It would need some code to get the duration.
So in short try this replacing the the duration field to the field you want;
//Condition
//current.state.changesTo('numberforclosedstate');
//Script
current.duration_field = gs.dateDiff(current.sys_opened_at.getDisplayValue(), gs.nowDateTime(), false);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 07:02 PM
I would instead recommend using METRICS as that is their point. TO measure that kind of stuff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2015 01:40 AM