50% found this document useful (2 votes)
593 views

IBM Maximo Customization Scripting and Formulas

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
593 views

IBM Maximo Customization Scripting and Formulas

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

IBM Maximo Customization

Scripting and Formulas

Oct 2018

Sean Stuckless
[email protected]
Who is this guy?

20 Years with
IBM

8 Years
12 Years with
Online
Maximo
Commerce

Developer Public
Scheduler KPIs Frameworks Supply Chain frameworks Integration
Engagement Mapping

2
DISCLAIMER

IBM’s statements regarding its plans, directions, and intent are subject to
change or withdrawal without notice at IBM’s sole discretion. Information
regarding potential future products is intended to outline our general product
direction and it should not be relied on in making a purchasing decision.
The information mentioned regarding potential future products is not a
commitment, promise, or legal obligation to deliver any material, code or
functionality. Information about potential future products may not be
incorporated into any contract. The development, release, and timing of any
future features or functionality described for our products remains at our sole
discretion.

© Copyright IBM Corporation 2018. All rights reserved.

3
Scripting and Formulas

Maximo thrives on customization and configuration

Fast and dynamic(if used properly)

Lots of integration points

Calculated fields using Formulas is natural

Workflow is OK, but, bulky for extending business logic

4
Scripting and Formulas
Can Delete
Actions Execute
Can Add Insert
Before
Save Update
Objects After
Duplicate Delete
After Commit
App Validate
Global Service Init On Setup

MIF/REST
Scripts
Library Script Init
Init Value
Attributes Action
Validate
7.6.0.5+
Conditions Get List
7.6
7.5
CRONs
5
Global 'service' var
logging

Invoke
channel

workflow

Real Time
Error
service var
Warning

Library script

Http calls 7.6.0.5+


7.6
Invoking 7.5
Endpoints
7
Service Examples

service.error(grp,key)

service.error(grp,key,params)

service.setWarning("po","nolines", None)

service.yncerror("asset", "assetpr",params)

service.logError("an error happened")

service.invokeChannel(channelname)

* service in `ctx` in MIF OS Scripts


MIF/REST Scripting Points -Exits
Out

Object
In
Structures
Query Before
(REST) Ext Exit
MIF Endpoints Action
Request User Exit
(REST)
After Ext
Exit
Enterprise
External
Service Response
Exit
External
Exit Before
MIF/REST Ext Exit
Publish
User Exit
Channel Before
After Ext
Event Exit Ext Exit
Filter User Exit
Request
After Ext
Invoke Channel Exit
7.6.0.5+
Response External
Exit 7.6
MMI 7.5
8
New in 7.6.1

Support for
Better support
Library Scripts Closing
for add-on Easier to use
Jython 2.7 with Multiple Maximo
module in Library Scripts
Functions Dialogs ('action'
Jython
Launchpoint)

9
Reusing Scripts – Library Scripts
❖ Current way to write Library Scripts.

Script 1 – CALC_MULT
r = a*b

Script 2 – CALC_ADD
r = a+b

10
Reusing Scripts – Library Scripts
❖ Current way to consume such a Library Script.

from java.util import HashMap


map = HashMap()
map.put("a",2)
map.put("b",3)
service.invokeScript("CALC_MULT",map)
res = map.get("r")

11
Reusing Scripts – Library Scripts
❖ What you can do now (make sure that you set the script to Allow
Invoking Script Functions).

Script - CALC

def mult(a,b):
return a*b

def add(a,b):
return a+b

12
Reusing Scripts – Library Scripts
❖ The script to consume it.

res = service.invokeScript("CALC","mult",[2,3])

13
14
Scripting Performance and Common Problems

➢ Not closing cursors


➢ Full access to Java and Maximo
➢ Too many relationships
➢ Too much database access
➢ Calling expensive methods (Change Status)
➢ Incorrect Lifecycle Event
➢ Calling "Save"
➢ Complex conditional Scripts

14
Dev Center + Future

➢ One Stop - Samples / References


➢ https://github.com/ibm-maximo-dev/maximo-scripting

➢ Auto Script Editor


➢ https://tinyurl.com/maximo-autoscript-editor
➢ Eventually will rolled into Maximo

➢ Auto Script Revisioning (Possible enhancement)

15
Formulas
Formulas

➢ Calculated Fields - Mathematical expressions


➢ Excel Like (Built-in functions)
➢ Access Related Fields
➢ Aggregation
➢ Applied to Objects and Attributes
➢ Extensible Function Framework in Java or Automation
Scripting
➢ Easy Access from DB Configure Application
➢ Persistent or Non Persistent
➢ Immediate or Asynchronous 7.6.0.6+

17
Formulas vs Scripting vs Java
C = f(A,B) - Java

A
Code

C
Code

B
Code

• Code Attached to Each Field


• Different Lifecycle for each Field
• Rebuild Maximo Ear
C = f(A,B) - Scripting

A
Script

C
Script

B
Script

• Script Attached to Each Field


• Different Lifecycle for each Field
• Configure Inputs/Outputs
C = f(A,B) - Formula

C
Formula
B

• Single Function
• Configured in Database Application
• C auto-magically updated when A or
B Change
Formulas in Maximo

➢ Approx 30+ Functions as of 7.6.1


➢ min, max, round, pct, if, date, abs, pow, sqrt, …
➢ Including aggregation functions, avg, sum, ...
➢ Can Reference
➢ Mbo attributes
➢ Maxvars
➢ System Properties
➢ Conditions
➢ Other Formulas

22
Example: Using Conditional Logic

IF(pressuremeter$lastreading > 60, 1,


IF(pressuremeter$lastreading > 20
&& pressuremeter$lastreading < 59, 2, 3))

➢ Nested Logic
➢ Relationships using the $ operator
➢ Implicit type conversion from ALN to double, boolean, date

23
Formulas - Prefixes

Prefix Description Example


prop System Property prop$propname * 1.5

var MAXVAR IF(var$maxvarname , 1, 2)

cond Maximo Condition field * IF(cond$conditionnum , 0.25, 0.75 )

isnull In Null Test IF(isnull$installdate , 0, 1)

prev Previous Value IF(priority > prev$priority, 1, 0)

modified Is Modified Test IF(modified$priority, 1, 0)

24
Formulas – Aggregation and Collections

Prefix Description Example


SUMF Sum SUMF("childtask" ,"estdur","actfinish" ,
DURATION(0,0,7,0,0,0 ))
COUNTF Count COUNTF("openwo","statusdate" ,
DURATION(0,0,10,0,0,0 ))
oldest Oldest by Date oldest$openwo$wopriority $statusdate

latest Newest by Date latest$openwo$wopriority $statusdate

count Row count count$childtask

➢ AVGF, MINF, MAXF also available

25
26
When to use Formulas vs Scripting

➢ Formula
➢ Mathematical Calculation

➢ Scripting
➢ Validation
➢ Complex Updates (if then else)
➢ Business Logic

26
27
Formula Performance and Common Problems

➢ Use aggregation sparingly


➢ Too many relationships
➢ Badly written user defined Functions
➢ Complex Conditional Formulas

27
THANK YOU

You might also like