Blog
Maximo Scripting - CanDelete/CanAdd Object Launch Point
This post is an excerpt from the Maximo 76 Scripting Features guide. We can control whether we can add or delete a Mbo using scripting Object Launchpoint “Allow Object Deletion” and “Allow Object Creation”. Can Add This is an Object Launch Point - “Allow Object Creation” where you can control whether you can add a new Mbo, given the current state of the system. This point pairs up with the canAdd callback that we have in the MboSet framework. Lets take a use case where we want to validate that a POLINE can be added to a PO only when the PO has the vendor information set. The script code to do that is shown below:
November 15, 2019
Maximo Scripting - Controlling Mbo duplicate
This post is an excerpt from the Maximo 76 Scripting Features guide. Say we want to hold the reference of work order from which we created (copied from) a new work order. We would create a custom attribute called “copiedfrom” in the WORKORDER object. We would then need to customize the duplicate process of the Workorder to store the “wonum” of the original workorder in the “copiedfrom” attribute of the newly duplicated mbo. To do this, we will create a vanilla script with the name .DUPLICATE. For example in this case we will name it WORKORDER.DUPLICATE to intercept the duplicate event. The name .DUPLICATE will intercept the duplicate event for the mbo named. We will have 2 implicit variables - mbo and dupmbo to leverage in this script. The mbo variable will point to the original mbo and the dupmbo will point to the newly duplicated mbo. We can now set the “copiedfrom” attribute using the script code below.
November 15, 2019
Maximo Scripting - Cron Tasks
This post is an excerpt from the Maximo 76 Scripting Features guide. Starting 76 we can write scripts for cron tasks too. It follows the same principle as the endpoint handler. We have a cron class - com.ibm.tivoli.maximo.script.ScriptCrontask that helps achieve this. We need to register that class as a new crontask in the crontask application. We then will create an instance of it and set the “scriptname” property to the name of the script that we want this task to run. Next we need to set the schedule and last but not the least - need to define the script. We are then good to go running this newly defined script with the crontasks. It is no different than any other crontasks and you can activate/deactivate the task or change the schedule as you would do in any other cron task.
November 15, 2019
Maximo Scripting - MMI
This post is an excerpt from the Maximo 76 Scripting Features guide. Maximo Management Interface provides a set of apis (REST/JSON apis) that helps a system administrator gets some insights on the state of the maximo runtime. The root url for that api is: GET /maximo/oslc And then you can dive deeper into each server (cluster members) using the /oslc/members api. We provide a bunch of apis that can help you introspect the servers. But of course we do not have all the apis that you will ever need. Fortunately there is a easy way to dynamically add these apis using automation scripts. Below I will provide a sample use case (a real one) that needed us to leverage that feature. Say you need to find out the servers locale as you trying to debug some locale related issue. You can quickly write up a automation script and serve it up as an MMI api using the MMI app - available from the Logging app action in Maximo - Monitor Environment Information. One of the cool aspects of MMI apis being - it gets distributed in every member server and using the MMI api framework - one can invoke these scripted apilets on each server.
November 15, 2019
Maximo Scripting - The mbo.add() method
This post is an excerpt from the Maximo 76 Scripting Features guide. It’s a common thing to conditionally set some defaults when a new mbo gets added. We have so far leveraged the Object Launchpoint Init event to do that. We would need to check for onadd flag there to make sure we are adding a new mbo and then set the attribute values. Another way to do that would be to create a script named .ADD. This will automatically add the script to the “add” callback right after the mbo add method execution has happened and right before the init() method gets called. You can use this script to now set default values conditionally. A sample script - ASSET.ADD shows how to default installdate attribute to current date only when the asset type is PUMP.
November 15, 2019
Maximo Scripting - Validation of non-persistent MBOs
This post is an excerpt from the Maximo 76 Scripting Features guide. Adding validation to the virtual (aka Nonpersistent) mbos (on execute 7609 feature). In this sample we are going use the change status dialog from the Asset Application to validate if the memo is filled in when the Asset status is set to BROKEN. We will write a Object launch point script – MEMOREQD, which will validate on OK button press of the dialog that memo is required for status BROKEN. The event will be “save/add”. This will map to the “execute” call back for non-persistent MBOs. The object name would be ASCHANGESTATUS. We used Python for this sample.
November 15, 2019
Maximo Scripting - Warnings and Errors
This post is an excerpt from the Maximo 76 Scripting Features guide. Maximo errors in 7.5 version used to get done by setting errorgroup, errorkey and params variables (full example here). woPriority = mbo.getInt("WOPRIORITY") if woPriority > 50: # Raise an error using a message errorgroup = "workorder" errorkey = "invalidPrio" Setting those did not stop the execution, as the execution will continue till the end of that script and then it will check the flags and throw the error. Often this may not be the expected behavior. To fix this issue, in 7.6 the global “service” variable can be used to throw errors and warnings.
November 15, 2019
Maximo Scripting - Yes/No/Cancel dialog
This post is an excerpt from the Maximo 76 Scripting Features guide. YNC (Yes, No, Cancel) interactions can now be implemented using automation scripts. We need to do some prep work before writing the script. First we need to define a message that support the YNC interaction. Make sure you have the message as informational (I) and support the Yes and No buttons. The use case below launches a yes/no dialog when the priority is set to 1. It asks the user if the he/she wants to set a default vendor for this. If the user select “yes” the script will set the default vendor A0001 and will mark the vendor field as required. If the user selects “no” vendor is marked as not required.
November 15, 2019
IBM Maximo Roadmap - September 2019
Here is the IBM Maximo product roadmap (September 2019). Trends are: UI modernization, mobility (Anywhere and Work Centers), APM (asset Performance Management), inventory optimization, Cognos analytics… View the Webcast Download the PDF
November 2, 2019
Special automation scripts .NEW .SAVE .DUPLICATE
I want to share a small trick I have learned from this presentation. It is an undocumented feature of Automation Scripts that will automatically launch a script based on a special naming convention. For example if you want to run a script each time a ASSET object is saved you just have to create an automation script (without a Launch Point) and call it ASSET.SAVE. There are just three events that can be used:
October 22, 2019