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 | Jul 28, 2020

Automation Scripts – A Powerful Maximo Feature

Automation Scripts are powerful features, used for writing, extending or altering the existing functionality to meet specific business requirements without java customization. Most popular scripting languages are Jython, Python and JavaScript. Automation Scripts were first introduced by IBM in Maximo 7.5 and the feature has been significantly improved in Maximo 7.6.

What is Automation Script?

Automation scripts are small, targeted pieces of code that can extend the product. An automation script consists of a launch point, variables with corresponding binding values, and the source code. Wizards are used to create the components of an automation script.

The many benefits of Automation Scripts

  • Scripts are executed on the server at time of call. i.e. the automation scripts are a server-side artifact, as opposed to a client-side one. Hence all your scripts are executed on the server side as opposed to say in the browser.
  • No compilation is required.
  • No outages are required to deploy the automation scripts.
  • Scripts can be enabled/disabled at run time without any outage.
  • Automation scripts provides default variables and bindings to enhance the functionality.
  • A single script can be applied to many attributes. The input variables can be modified.
  • Automation script works as same as Java classes.
  • Easy to develop and implement.
  • Scripts are stored in the Database as metadata.
  • They are supported with upgrades and Migration Manager.
  • No stress on upgrades and you are not going to lose your class if you upgrade Maximo.
  • Automation scripts require no Java skills or Maximo API knowledge.
  • Automation scripts are fired after the MBO, Field classes. Hence its does not break the implemented Maximo OOB functionality; in turn it extends the functionality.

When can Automation Scripts be used?

Automation scripts support calls from Maximo Attributes/Applications, Actions for Escalations or Workflow, and custom points such as Workflow Condition Nodes and Conditional Expressions and Integration framework.

The source code must be written in the languages that are supported by the following script engines:

  • Mozilla Rhino, version 1.6 release 2
  • Jython, version 2.5.2

Examples of when Automation Scripts can be used

Example 1: Remove Non-ASCII characters in the Description attribute

Create Attribute Launch point

~ Create Attribute Launch Point ~

Launch Point: BPD_FLD_PO_DESC_RMV_NONASCII – Remove Non-Ascii Characters from PO Description

Object: PO

Attribute: DESCRIPTION

Events: Validate

Script: New

~ Step 1 ~

~ Step 2 ~

~ Step 3 ~

Source Code:

def onlyascii(char):

if ord(char) < 32 or ord(char) > 126: return ”

else: return char

try :

v_text=filter(onlyascii, v_text)

except (RuntimeError, TypeError, NameError) :

v_text=”

Example 2: Check to ensure that dates are not set in the future

~Create Attribution Launch Point ~

~ Step 1 ~

~ Step 2 ~

~ Step 3 ~

Source Code:

from psdi.server import MXServer

from psdi.mbo import MboValue

if (app is None or app == “” ) and mbo.getOwner() is not None:

app = mbo.getOwner().getThisMboSet().getApp()

if app is not None:

srcAttributes = [“INVOICEDATE”, ” EXCHANGEDATE”]

for index in srcAttributes:

current = MXServer.getMXServer().getDate()

val = mbo.getMboValue(index).getDate()

if val is not None and val.before(current):

errorkey=”invalidDate”

errorgroup=”invoice”

Example 3: Assign a job plan description to PM Work Orders description

~ Create Object Launch Point ~

~ Step 1 ~

~ Step 2~

~ Step 3 ~

Source Code:

from psdi.mbo import Mbo

from psdi.mbo import MboConstants

 

jpdesc=mbo.getString(“JOBPLAN.DESCRIPTION”)

mbo.setValue(“description”, jpdesc, MboConstants.NOACCESSCHECK)

Example 4: Reopen Closed Work Order

~ Create Action Launch Point~

~ Step 1 ~

~ Step 2 ~

~ Step 3 ~

from psdi.mbo import SqlFormat

from psdi.mbo import MboConstants

from psdi.server import MXServer

 

if (mbo != None and mbo.getString(“status”)==”CLOSE”):

pstatusSet = mbo.getMboSet(“$MAXWOSTATUS”,”WOSTATUS”,”wonum = :wonum and siteid = :siteid and status != :status and changedate = (select max(m.changedate) from wostatus

m where m.siteid = :siteid and m.wonum = :wonum and m.status != :status)”);

pstatus = pstatusSet.getMbo(0)

if (pstatus != None):

p_status = pstatus.getString(“STATUS”);

c_statusDate = MXServer.getMXServer().getDate();

#set the status on the work order

mbo.setValue(“status”, p_status,

MboConstants.NOACCESSCHECK)

mbo.setValue(“statusdate”, c_statusDate,

MboConstants.NOACCESSCHECK)

mbo.setValue(“historyFlag”, False,

MboConstants.NOACCESSCHECK)

 

#add a record in the status history table

woStatusMboSet = mbo.getMboSet(“WOSTATUS”)

woStatusMboSet.add(MboConstants.NOACCESSCHECK);

woStatusMboSet.setValue(“memo”, “Reopen Closed Work

Order”)

woStatusMboSet.save()

else:

errorkey=”Cannot Reopen WO – Error – ” +

mbo.getString(“WONUM”) + ” – ” + mbo.getString(“status”)

errorgroup=” workorder”

else:

errorkey=”Cannot Reopen WO – Not Closed – ” +

mbo.getString(“WONUM”) + ” – ” + mbo.getString(“status”)

errorgroup=”workorder”

Saravanaperumal Sankaranarayanan

Saravanaperumal Sankaranarayanan

Saravanaperumal is the Principal Consultant at BPD Zenith. He has gained IT industry experience encompassing a wide range of skill set, roles and industry verticals. He was involved in business analysis, process designing, requirement gathering, data loading, data mapping, user training and user/system testing. His passion for MRO pushed him towards Maximo. He has implemented and enhanced Enterprise Asset Management systems (IBM Maximo) in Oil & Gas, Nuclear Energy, Transportation Industries clients in America, Europe and ANZ. Out of office, he enjoys spending time with family, long-distance drives, and of course, he follows Cricket and AFL. His favourite home teams are Perth Scorchers and West Coast Eagles.

0 Comments

Submit a Comment

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

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

Meet the Team – Jitesh Kalyan

Meet the Team – Jitesh Kalyan

1. What is your position at BPD Zenith? I am a Maximo technical consultant. My day to day activities include supporting our clients with the implementation and maintenance of their applications, primarily IBM Maximo. I also work on DataSplice, a Mobile app integrated...

What’s new in IBM Maximo version 7.6.1.2

What’s new in IBM Maximo version 7.6.1.2

IBM released Maximo v 7.6.1.2 on July 24, 2020 to bring new and enhanced functionality to the user community of a leading, world-class asset management solution. IBM continues to assist the Maximo community optimise and enhance the performance of their assets while...

An Introduction to the Service Requests Work Center

An Introduction to the Service Requests Work Center

Service Requests Work Center The Service Request tool is used to create service requests, monitor the status of existing active requests as well as view completed requests. You have the ability to create SRs on your desktop computer, laptop computer, or mobile device....

Moving to Predictive Maintenance Today – For a Better Tomorrow

Moving to Predictive Maintenance Today – For a Better Tomorrow

Maintenance Strategy - Uptime and Reliability Focused For all asset intensive companies, regardless of industry vertical, maintenance strategy is key to achieving uptime and reliability targets.  While there are a number of methods of measuring the maturity of your...

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.