The BPD Blog

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 Custom Add-on Products

Maximo Custom Add-on Products

There are instances when organizations want to add client-specific validations, functionalities or new applications to Maximo Asset Management that don’t exist out-of-the-box. Luckily, Maximo caters to this with its add-on methodology and packages can be installed...

Maximo buzz kills – working your way around them

Maximo buzz kills – working your way around them

In the world of Maximo, there are often little things that you wish you wouldn’t have to encounter. Slow start centers, slow search results and that dreaded spinning wheel on the screen are just some of the buzz kills that users report. If you can rule out issues of...

The ease and power of automation scripts in Maximo

The ease and power of automation scripts in Maximo

Many of us in the Maximo space are appreciative of the power of automation scripts, however, might not be entirely familiar with various scripting languages like Javascript, Python and their API. How is Python different to Java and Script? Python created by Guido Van...

Monitoring license usage using BIRT report and views

Monitoring license usage using BIRT report and views

Maximo users can be categorised based on their license usage. The conditions of the contract or agreement with the service provider will outline the licenses which a client is eligible to use. The 4 different licence usages/types include Authorised, Limited, Express...

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

Listen to your assets!

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