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 | Jan 29, 2020

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 Rossum, was first released in 1991 and is currently powering big players like Netflix and Instagram. Guido compares Python to languages like Java or Swift but points out a critical difference between Python and the latter two. He contends that Java and Script are great resources for software developers and programming, but Python should be utilised by those who code to handle data.

~ Netflix and Instagram are both powered by Python ~

Jython – a product of Java and Python

Jython – a value-added version of Python is a language that runs on the JVM. Jython’s pivotal strengths include scripting as well as exploring and debugging code. Jython’s interpreted nature allows users to work simultaneously with Java without a compiler and manipulating live objects on the fly. Essentially, Jython has birthed from merging Java and Python together.

~ Jython is a product of Java and Python ~

One of the key advantages of using automation script is that it allows users to utilise the power of multiple languages. A simple example would be to check if an attribute in Maximo has been set. Sometimes when we call getString(“DESCRIPTION”) we receive a NULL value back and at other times we receive a blank string. In Java we must write both checks like getString(“DESCRIPTION”)!=null and getString(“DESCRIPTION”)!=””. In Jython, this process is simplified as we can just say mbo.getString(“DESCRIPTION”) and it will handle both scenarios.

Below are a few techniques in Jython that were used in a recent Maximo integration project.

1. DateTime formatting

The ‘external’ system would send their date in the format dd/MM/yyyy HH:mm, while Maximo’s MIF would only accept dates in the format yyyy-MM-dd’T’HH:mm:ss.
After conducting some research into this issue, we found that instead of using Python’s date time conversion API, we could use the good old Java’s SDF (Simple Date Format) in the script.

duedate = erData.getCurrentData(“TARGETFINISH”)
dateFormat = “dd/MM/yyyy HH:mm”
sdfServer = SimpleDateFormat(dateFormat)
cTime = sdfServer.parse(duedate)
erData.setCurrentData(“TARGETFINISH”,cTime)

Note that once I have parsed the string into date, all I had to do was set the value. I didn’t have to explicitly format it to yyyy-MM-dd’T’HH:mm:ss. What makes it possible to do that? Contact us for the answer

2. Split a string

The requirement was to split the value from Long Description field based on the sub-string ‘NOTES:’, and it was implemented using the split function of Python.

desc = erData.getCurrentData(“DESCRIPTION_LONGDESCRIPTION”)
desc1,desc2 = desc.split(‘NOTES:’,1)

3. Truncate a string

DESCRIPTION attribute of the object only accepts 100 characters, and hence the incoming value had to be truncated as below.

propdesc = erData.getCurrentData(“DESCRIPTION”)
propdesc = propdesc[:99]
erData.setCurrentData(“DESCRIPTION”,propdesc)

Automation scripting features in Maximo 7.6.1.1

A scripting editor has been embedded in automation script application. The latest version of Maximo has the following features:

  • Syntax highlighting and Line numbers for improved readability
  • Collapsible code blocks
  • JavaScript validations prior to save
  • Auto-complete reserved words, common functions, etc for Python and JavaScript
  • Supports some auto-completion of existing variables and methods
  • Tab will indent the code instead of taking you to the next Maximo Field
  • Supports Ctrl-z for Undo

If you’d like to learn more about automation scripting, here is an IBM link that gives you a list of web pages showcasing various other techniques. Any comments or further queries, please contact me via BPD Zenith.

Zoe Tattersall

Zoe Tattersall

We’re more than just your type. We do awesome, too. And websites, graphics, product photography and video content. Sevah Creative™️ a boutique creative agency bringing our big picture minds for business strategy to awesome design, marketing and content. Whether you’re a services, product or eCommerce business, we create a cohesive brand experience across digital channels, offering slick and compelling touch points that convert and move people to action.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

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...

Reinvent the Wheel with BPD Zenith’s Maximo Accelerators

Reinvent the Wheel with BPD Zenith’s Maximo Accelerators

I was recently involved in preparing a business case for a Maximo implementation, and as a part of process I spent considerable time analyzing and evaluating the best approach. In essence, I was trying to find the optimum balance between minimizing the length of the...

Defence Seaworthiness – A session from AMPEAK 2021

Defence Seaworthiness – A session from AMPEAK 2021

I recently got the opportunity to attend Asset Management Council of Australia’s AMPEAK conference. It has been a great experience interacting directly with the true practitioners of Asset Management, and understanding some of the technology challenges that they are...

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…

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.