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.


9 Recommendations For A Successful SAP & IBM Maximo EAM Interface

9 Recommendations For A Successful SAP & IBM Maximo EAM Interface

Integration is often a key component for getting the most out of your critical IT applications. Modern Enterprise Asset Management systems such as IBM Maximo are designed for integration which can expand their capabilities and allow the flexibility that the industry...

How to call a Report directly from the Action Menu in IBM Maximo

How to call a Report directly from the Action Menu in IBM Maximo

In IBM Maximo, it’s possible to add a direct print option to a report. This adds a printer icon to the toolbar and allows you to run the report with just one click. But for reports where there are parameters required before running, this is not possible… Usually, a user will have to click the “Run Reports” action, then find their report in the list of all reports available for that application. They then click on the one they want before being taken to the IBM Maximo Reports Request page. In this blog I’ll show you how to get around that problem. in our example we use an Action launch point for an Automation Script and link it to a menu item in IBM Maximo Application Designer…

Helpful tips to remember when starting a Maximo Implementation

Helpful tips to remember when starting a Maximo Implementation

After nearly 20 years of implementing Maximo for various organisations across a myriad of industries, there are some basic design principles that I like to follow on a new (greenfield) Maximo installation. Please note that these are some of my personal preferences but...

Implementing Drill-through in a BIRT report

Implementing Drill-through in a BIRT report

More often than not, we may be working with a report which lacks all the necessary details about a particular Work Order or asset. In this instance, we need to access Maximo and retrieve the relevant record to obtain the information we are after. Wouldn’t it be so...

Maximo Inspection Forms extension for Procurement

Maximo Inspection Forms extension for Procurement

Since the release of Maximo Work Centers, Maximo 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...

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.