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"/>
</tablebody>
</table>
<buttongroup id="copypolines_2">
<pushbutton default="true" id="copypolines_2_1" label="OK" mxevent="dialogok"/>
<pushbutton id="copypolines_2_2" label="Cancel" mxevent="dialogcancel"/>
</buttongroup>
</dialog>[/xml]
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”)
selectedMBOs.resetWithSelection()
#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
mbo.getOwner().setModified(True)[/python]
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.

0 Comments

Resourcing for Success

Resourcing for Success

Project resourcing is frequently one of the hot topics in our meetings. I frequently receive questions such as: Can we start the project now? Can we commit this resource to deliver from start to finish? Can we upskill one of our techs? Can we provide an additional...

What is Asset Performance Management?

What is Asset Performance Management?

What is Asset Performance Management? Introduction As a definition, Asset Performance Management (APM) encompasses the capabilities of data capture, integration, visualization, and analytics tied together for the explicit purpose of improving the reliability and...

Maximo Relationships

Maximo Relationships

In this blog I will be explaining what a Maximo Relationship is, how to create one, and, the benefits of having Maximo Relationships. What is a relationship? The way in which two or more things are connected, or the state of being connected.Why do we need Maximo...

Maximo Data Imports: A simplified guide

Maximo Data Imports: A simplified guide

All your Maximo data import needs simplified Being able to manage data loads and data extracts is a powerful ability. It can substantially improve processes and reduce delays. Maximo offers not one but multiple ways of handling data. Equipped with user-friendly error...

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

Discover the Maximo Application Suite

Discover BPD's award winning Maximo and IoT Services

Come with BPD Zenith to the future of Asset Management

Partner Ecosystem

BPD Zenith partners with a diverse array of the world’s top Technology, Business and Solution Integration leaders.