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.
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.
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:
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=”
~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”
~ 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)
~ 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”
If you need help with automation scripts or have any questions about the contents of this blog, please contact us.