Tracking elapsed time in work order status history

A common requirement from my clients is to track how much time work orders have been in each status.
IBM Maximo already has the Work Order History dialog that displays the date and time of each status change. Unfortunately it may be not straightforward for a user to calculate the time spent in each step of the process or to develop a KPI to set processing time goals in your work management flow.

What I usually implement is a very simple time-tracking feature that just displays the elapsed time (time spent) attribute for each row. Note how the new history dialog is much more readable now.

To achieve this result we just need three configurations:

  1. A new attribute to store the ‘elapsed time’ value in the WOSTATUS table.
  2. An automation script to calculate and set the value in the custom attribute.
  3. Modify the Work Order history dialog to display the new attribute.
Note that he same technique can be implemented for tickets (service requests) with very few modifications.

Elapsed Time attribute

Open Database Configuration application and create a new field like this:

  • Object: WOSTATUS
  • Attribute: XXXELAPSEDTIME (replace XXX with your own custom prefix)
  • Title: Time spent (or Elapsed Time)
  • Type: DURATION

Apply database configuration changes to create the new field in the database.

Automation Script

Open Automation Scripts Applications and create the following script.

# Script: WOSTATUS_TIMETRACKING
# Launch Point: Object (Save - Add - After Save)
# Object: WOSTATUS
# Calculate the time spent in previous status and update XXXELAPSEDTIME

from psdi.mbo import Mbo
from psdi.mbo import MboConstants

# Perform calculation only on interactive sessions to avoid the following error when generating PMs in the background.
# BMXAA3212E - Error while generating work order for PM. BMXAA8229W - Record WOSTATUS has been updated by another user.
if interactive:
  # get latest status history records
  shSet = mbo.getMboSet("$WOSTATUS$", "WOSTATUS", "wonum=:wonum and siteid=:siteid")
  shSet.setOrderBy("changedate desc")

  # calculate elapsed time
  if shSet is not None:
    lastSh = shSet.getMbo(1)
    thisSh = shSet.getMbo(0)
    if lastSh is not None and thisSh is not None:
      diff = (thisSh.getDate('CHANGEDATE').getTime() - lastSh.getDate('CHANGEDATE').getTime()) / float(3600000)
      lastSh.setValue("XXXELAPSEDTIME", diff, MboConstants.NOACCESSCHECK+MboConstants.NOVALIDATION)

Application dialog

The new WOSTATUS.XXXELAPSEDTIME attribute is now automatically updated by the script so we just have to display it in the application dialog.
Open Application Designer and search for WOTRACK application.
Edit the viewhist dialog and add the XXXELAPSEDTIME attribute in the first table.

Tracking elapsed time in work order status history

2 thoughts on “Tracking elapsed time in work order status history

  1. Is there a way to get just the working time. I mean based on the calendar that was used to apply SLA. Because some customers are more interested in time spent on ticket between their working time.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top