How to keep running total of hours for a ticket.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 10:56 AM
I have created two fields on Incident table:
Time Spent (Value in minutes of time spent working on this item for current update)
Total Time Spent (Sum of all Time Spent entries on the ticket)
I need assistance with writing the business rule that updates the Total Time Spent field every time the Time Spent field is updated with a new value. This will allow us to calculate the total time spent on the ticket so we can compare it with the originally estimated level of effort.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 11:27 AM
Hi,
Below is what we ended up using to accomplish this:
(function executeRule(current, previous /*null when async*/) {
if (current.u_time_spent.changes()) {
var timeSpent = parseInt(current.u_time_spent, 10) || 0;
var currentTotal = parseInt(current.u_total_time_spent, 10) || 0;
current.u_total_time_spent = currentTotal + timeSpent;
current.u_time_spent = '';
}
})(current, previous);