From blogs to case studies to news, we love sharing our tips and tricks for asset management, cloud, IoT and smarter operations.

by | Dec 3, 2018

Automation and Dialogs

Recently, I’ve seen a lot of online posts asking IBM for the ability to be able to tie an Automation Script to the Dialog OK button. I have a solution! This blog post should allow Maximo Developers to use Automation Scripts in parallel with Dialog boxes.
The problem faced isn’t tying the action to the button (that is basic Automation Scripting functionality), the problem is closing the Dialog once the Automation Script has fired as you can only tie one action to the button and you can’t close a Dialog box from Automation Scripts as you don’t have the visibility of variables you would need. So, currently you can either close the Dialog ORfire the Automation Script.
To work around this without the need for Java Bean Classes I’ve left the okdialog action on the OK button which handles the Dialog close functionality and I have my Automation Script firing on save of the main record. With the Dialog box set to save on “UNLOAD” (close), the main record is saved as standard by Maximo once the Dialog closes and so the Automation Script is fired when the Dialog is closed.

The Requirements

In this example, we will be using a requirement to be able to copy PO Lines from any other PO to the open PO. This will be done by selecting the PO Lines to copy from a Dialog box and copying them when the Dialog box closes.

Steps to Implement

First, I created a new relationship from the PO Object to the POLINES Object. The new relationship is required for two reasons:

  1. To return the PO Lines we want to be able to select on the Dialog;
  2. To identify when the Dialog is opened from Automation.

The relationship brings back all PO Lines which aren’t currently on the open PO.
[sql] ponum != :ponum AND siteid = :siteid AND orgid = :orgid [/sql]

Next, I created the Dialog which uses the relationship to display the PO Lines.

[xml] <dialog id="copypolines" label="Copy PO Lines" parentdatasrc="MAINRECORD" relationship="ALLPOLINES" savemode="ONUNLOAD">
<table id="copypolines_table" inputmode="readonly" label="PO Lines" selectmode="multiple">
<tablebody displayrowsperpage="20" filterable="true" id="copypolines_table_tablebody">
<tablecol filterable="false" hidden="false" id="copypolines_virtualset1_tablebody_1" mxevent="toggleselectrow" sortable="false" type="event"/>
<tablecol dataattribute="ponum" id="copypolines_tablebody_1" mxevent="selectrecord" type="link"/>
<tablecol dataattribute="polinenum" id="copypolines_tablebody_4" mxevent="selectrecord" type="link"/>
<tablecol dataattribute="description" id="copypolines_table_tablebody_2"/>
<buttongroup id="copypolines_2">
<pushbutton default="true" id="copypolines_2_1" label="OK" mxevent="dialogok"/>
<pushbutton id="copypolines_2_2" label="Cancel" mxevent="dialogcancel"/>
Important things to notes about the Dialog:

  1. The Parent Data source is set to MAINRECORD. This is so the relationship runs off the open PO Record.
  2. The Relationship is set to the one we created earlier. This Dialog will be the only place this Relationship is used in Maximo, so we can identify when the Dialog is launched in Automation.
  3. The OK Button has an MX Event of
  4. The Save Mode is set to ONUNLOAD meaning the dialog will save the main record when OK is pressed.

Next, we need to create an Automation Script to tell the PO to do something on Save. This Automation Script has a basic Object Launch Point on Object PO before save for Add and Updates.

The Automation Script fired on PO does the following steps:

  1. Get all the selected PO Lines from the Dialog using the ALLPOLINES relationship defined and used above.
  2. Loop through the selected lines and copies Line Type and Description to new lines on the current PO.

[python] #Get all selected PO Lines
selectedMBOs = mbo.getMboSet(“ALLPOLINES”)
#Return the first selectet PO Line
selectedMbo = selectedMBOs.moveFirst()
#Create a PO Line MBO Set from the current PO so we can add new lines to it
poLines = mbo.getMboSet(“POLINE”)
#Loop through all PO Lines which were selected on the Dialog
while selectedMbo != None :
#Add a new PO Line for the Selected Line1
newLine = poLines.add()
#Copy details from the selected line to the new line
newLine.setValue(“LINETYPE”, selectedMbo.getString(“LINETYPE”))
newLine.setValue(“DESCRIPTION”, selectedMbo.getString(“DESCRIPTION”))
#Move onto next selected line
selectedMbo = selectedMBOs.moveNext()[/python]
The final step is to tell the Dialog to mark the PO as modified so the Dialog save action will actually fire when the Dialog closes. To achieve this, I’ve created an Automation script which fires on init of the POLINE Object.

The Automation Script itself checks the Relationship being used to initialise the POLINES object is our ALLPOLINES Relationship and if it is it marks the PO’s modified flag as true.
[python] #Check relationship being used for the PO Lines MBO Set
if mbo.getThisMboSet().getRelationName() == “ALLPOLINES” :
#Mark the owning PO as Modified
Now if we open a PO (This one has no lines):

Open the Copy PO Lines Dialog and select random lines:

Now when we click OK, the lines will be copied to the PO.

Chris Brown

Chris Brown

As an Engineer, Chris is one of BPD Zenith’s most experienced developers. With over 10 years of in-depth technical experience, Chris is the most certified member of the UK team, specialising in Maximo versions 4 to 7.6, Tivoli Process Automation Engine, DB2, SQL Server and Oracle DBA. Chris can develop custom applications and extend the functionality of standard Maximo applications using both the Maximo Application Designer and the Java programming language to meet client requirements. He is knowledgeable in developing custom reports and modifying existing reports using both Actuate and BIRT report designers.


Maximo Inspection Forms extension for Procurement

Maximo Inspection Forms extension for Procurement

Since the release of Maximo Work Centers, Inspection Forms have gained popularity in the work management circles, however, this powerful tool seems to be under-utilized for Maximo’s purchasing module. The below is an attempt to harness the potential for procurement. A...

An Introduction to Conduct an Inspection Work Center

An Introduction to Conduct an Inspection Work Center

Conduct an Inspection Last week we reviewed the “Manage Inspection Forms” tool in Maximo. This week we will look in to the “Conduct an Inspection” tool which is very closely related to the Manage Inspection Forms tool.  One of the primary responsibilities of an...

Introduction to the Manage Inspection Forms Tool

Introduction to the Manage Inspection Forms Tool

Manage Inspection Forms Tool This blog will provide a quick overview and use case of the Manage Inspection Forms Tool. This is part of a series of blogs looking at Work Center functionality and our experience in implementing them.  The Manage Inspection Forms tool is...

Introduction to the Work Supervision Work Center  

Introduction to the Work Supervision Work Center  

Work Supervision Work Center   This blog will provide a quick overview and use case of the Work Supervision Work Center. This is part of a series of blogs looking at Work Center functionality and our experience in implementing them.  The Work Supervision Work Center...

Introduction to the Work Execution Work Center

Introduction to the Work Execution Work Center

Work Execution Work Center This blog will provide a quick overview and use case of the Work Execution Work Center. This is part of a series of blogs looking at Work Center functionality and our experience in implementing them.  Maximo Work Centers are visually dynamic...

Sign up to our free newsletter to explore emerging technologies, industry events and Maximo best practice.

Come with BPD Zenith to the future of Asset Management

Listen to your assets!

Most companies are aware of waste in their preventative maintenance efforts, but aren’t quite sure how to eliminate it.