October 18, 2013

Object Quick Summary

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 QuickSummary 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.
  • Attribute: WOSUMMARY
  • Title: Summary
  • Type: CLOB
  • Persistent: false
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="QuickSummary">
    <section id="summary_s1">
      <richtexteditor dataattribute="WOSUMMARY" height="400" id="summary_s1_wosummary" plugins="[]" extra_plugins="[]"/>
    </section>
  </tab>
  </tabgroup>
  </clientarea>
  <include id="pageFooter"/>
</page>
...


Script

The last configuration steps is to create the script that will fill the WOSUMMARY field and attach it to the rich text control. The sample script retrieves all the necessary information from the work order and builds an HTML string that it is used to set the field value.

Goto System Configuration > Platform Configuration > Automation Scripts.
Select Action > Create Script and enter this information:
  • Script: WOSUMMARY
  • Description: Init Workorder summary
  • Script language: jython
  • Source code: paste the code below

from java.lang import StringBuilder
from psdi.mbo import MboConstants


val = StringBuilder()

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

# retrieve work log records and writes them in the buffer
worklogSet = mbo.getMboSet("MODIFYWORKLOG")

val.append("<hr>")
val.append("<h2>WORK LOG</h2>")
val.append("<hr>")

currMbo=worklogSet.moveFirst()

while currMbo is not None:
    
        val.append("<h3>" + currMbo.getString("DESCRIPTION") + "</h3><br>")
        val.append(currMbo.getString("DESCRIPTION_LONGDESCRIPTION") + "<br>")
        val.append("<hr>")
        currMbo=worklogSet.moveNext()
    

#  sets the formatted string in the attributes value
mbo.getMboValue("WOSUMMARY").setValue(val.toString(), MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION)

Click on the Create button.
Now you have to attach the script to the WOSUMMARY field. Select Action > Create Script with Object Launch Point and enter the following information:

  • Launch Point: WOSUMMARY
  • Descriptions: Fills the workorder summary
  • Object: WORKORDER
  • Active: True
  • Events: Initialize
  • Script: WOSUMMARY
Accept defaults on the other dialogs and create the launch point.

Now you are done. Open a sample Workorder and go the the QuickSummary tab and look at the results.


Further improvements

There are many ways to improve the QuickSummary feature.

Obviously you can extend the example to include your own fields and formatting to better fit your needs.

Look at how HTML tags have been used to format the output in the script. This means that you can improve the formatting of the summary to enhance readability.


Thanks to my colleague Dirk Hillmer who has helped me with TPAE scripting.

6 comments:

  1. First of all, thank you for the wonderful tutorial. I was wondering what are the steps necessary to make it work on 7.x since there's no automation scripting feature there?

    ReplyDelete
  2. When you display all records in the table, initialization action will be performed on each record....

    ReplyDelete
  3. can this feature be inserted into SR and INCIDENTS

    ReplyDelete
  4. I have a client that needs something similar to this but on the start center. They'd like to have a result set with all work logs from the past 24 hours (columns: CREATEDBY - WONUM - SUMMARY - DETAIL). Any ideas for making that work since there's no "work logs" application from which to create a start center query?

    ReplyDelete
  5. Hi Bruno your tutorial is great help, but I need more details for script.
    I created one script to duplicate all important information, the script is working perfectly but I need to go to the page that's created, this is my problem.
    Is there any command that I can do to get that functioning ? (thought script)
    Thanks

    ReplyDelete