Display a summary of an object

NOTE: This techniques requires Java programming. A similar article describes how to achieve the same results with scripting.

One of the customer that I'm working with is heavily relying on work logs. Unfortunately, the work logs are displayed in a standard table so there is no way of quickly displaying all the logs entered by the users.



The solution I have designed is a Summary tab in the Work Order Tracking application that displays the main attributes of the selected work order together with the historical work logs in one single text box.



The described solution relies on the Rich Text editor control available in TPAE 7.5 but can be easily adapted to a standard multiline text box available in previous version of Maximo.
Here are the configuration steps.


Database Configuration

The first step is to define a virtual (non persistent) attribute that will be used to display the work order summary text.

Open WORKORDER object in Database Configuration and add the following attribute.
Save and apply database changes.


Application Designer

The second step is to add a new tab to the WOTRACK application that contains just a large texbox that will display the attribute defined above.

Open WOTRACK application in Application Designer and export application XML. Open the wotrack.xml file with a text editor and add the following lines just before the </tabgroup></clientarea> tags.
Here is how the file should look like (the text in bold is what needs to be added).

  ...
  <tab id="summary" label="Summary">
    <section id="summary_s1">
      <richtexteditor dataattribute="WOSUMMARY" height="400" id="summary_s1_wosummary" plugins="[]" extra_plugins="[]"/>
    </section>
  </tab>
  </tabgroup>
  </clientarea>
  <include id="pageFooter"/>
</page>
...


Java class

The last configuration steps is to write the Java class that has been attached to the WORKORDER.WOSUMMARY field. This piece of code will retrieve all the necessary information from the work order and build an HTML string that will be assigned to the field string value.

Open your development environment and create a mxdev.app.wo.FldWoSummary class like this.

package mxdev.app.wo;

import java.rmi.RemoteException;

import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.mbo.MboValueAdapter;
import psdi.util.MXException;

public class FldWoSummary extends MboValueAdapter
{
  public FldWoSummary(MboValue mbv) throws MXException
  {
    super(mbv);
  }

  public void initValue() throws MXException, RemoteException
  {
    super.initValue();

    MboRemote wo = this.getMboValue().getMbo();
    StringBuilder val = new StringBuilder(); 

    // retrieve attributes and writes them in HTML format in the buffer
    val.append("ID: " + wo.getString("WONUM") + "<br>");
    val.append("Description: " + wo.getString("DESCRIPTION") + "<br>");
    val.append("Location: " + wo.getString("LOCATION") + "<br>");
    val.append("Asset: " + wo.getString("ASSETNUM") + "<br><br>");

    // retrieve work log records and writes them in the buffer
    MboSetRemote worklogSet = wo.getMboSet("MODIFYWORKLOG");

    val.append("<hr>");
    val.append("<h2>WORK LOG</h2>");
    val.append("<hr>");
  
    for(MboRemote currMbo=worklogSet.moveFirst(); currMbo!=null; currMbo=worklogSet.moveNext())
    {
      val.append("<h3>" + currMbo.getString("DESCRIPTION") + "</h3><br>");
      val.append(currMbo.getString("DESCRIPTION_LONGDESCRIPTION") + "<br>");
      val.append("<hr>");
    }

    // sets the formatted string in the attributes value
    getMboValue().setValue(val.toString(), Mbo.NOACCESSCHECK | Mbo.NOVALIDATION);
  }

}

Deploy the java class in Maximo EAR file.

You can see how HTML tags have been used to format the output.
Obviously you can extend the example to include your own fields and formatting to better fit your needs.

Labels: , , ,