Your first Automation Script in Maximo 7.5

If you have used Rules Manager, QuickPick or Field Control then you are already familiar with the Automation Script in Maximo. The Automation Script is basically a developers tool to enable you to develop custom business rules without having to develop custom java class in Maximo.

With the Automation Scripts application, you can create scripts to automate tasks based on the events or attributes of a business object, or based on actions or custom conditions. You can create a script in any of several supported scripting languages, and execute the script without having to recompile Java files or restart the server.

In previous version of Maximo, if you wanted to change a field value based on another field, you would have to write a custom Java class, compile it, include it in your businessobjects.jar file, redeploy the maximo.ear, and run database configurations to use the new Java class. Now you no longer have to do that. The scripting engine is a powerful tool and you don’t even need to know Java because you can write it in your favorite programming language such as Jyton or even javascript.

Overview of Automation Script

There is already a detailed document on understanding the basics of the scripting engine, so you can read that in detail if you want. There are basic rules that you need to follow for the script to work. The first thing is the concept of a launch point. There are different types of launch points such as an Object launch point, Attribute launch point, Action launch point and a custom launch point. This is where you can select the type you want to automation script to start from. We will be using the Attribute launch point in the tutorial later. So when an attribute is modified the launch point will then be executed on that attribute.

There are also implicit variables that are supplied to the automation script that you can use in your code. These are already defined for you so you can just use them without initializing them. You can read the document for the complete list, but the most important ones are:

  • app – Name of the Maximo application which initiated the script execution.
  • user – Name of the user whose action initiated the script execution.
  • mbo – The current mbo in the context of the script execution. For example in case of the Object Launch Point this will be the Mbo which is generating the events on which the script framework is listening on. For attribute launch point this is the attributes owner mbo. For Action launch point this is say the Escalation or workflows mbo.
  • mboname – The name of the current mbo in the context of the script execution.

These will help you modify the MBO’s however you see fit.

Writing your first script

In this tutorial, I will show you how to create your first script. This script will execute from an attribute and based on that attribute, it will update another field. We will check the DESCRIPTION field and if the description is equal to “Test”, we set the WOPRIORITY field to 2.

First, we need to open the Automation Script application. Go To -> System Configuration -> Platform Configuration -> Automation Scripts. Click on Select Action -> Create -> Script with Attribute Launch Point.

Create launch point ID and description and set the object = ‘WORKORDER’ and attribute = ‘DESCRIPTION’ and click next. In the next screen, enter a unique script ID and then select your script language. Here we are going to select ‘javascript’. That’s what I’m familiar with, but the beauty of this is that you can select any language you want. Click next. Now we can start to write our code. This code will check the current value of the DESCRIPTION field is equal to ‘Test’ and then set the WOPRIORITY field to 2 if it’s true.

if ( mbo.getString('DESCRIPTION') == 'Test' ){
     mbo.setValue('WOPRIORITY', '2');

You will notice that I used the variable ‘mbo’ which is already provided for me, so I can simply call the methods on that Mbo object. Finally click create and make sure you change the status of the new script to ACTIVE.

Now it’s time to test your new script, go to Work Order Tracking and create a new work order. Enter ‘Test’ in the description field and hit tab. You should now see the Priority field value equal to 2.

Series Navigation< Prevent completion / closure of work orders with open labor transactionsDisable Maximo business rule with an Automation Script >

Did You Know...

As Maximo Experts, we have developed several add-on products for Maximo that mobilize the work force, simplifies assignments, provides ad-hoc reporting capabilities and facilitates the seamless integration of Service Requests into Maximo.

Check out our products by clicking on the following links: EZMaxMobile, EZMaxPlanner and EZMaxRequest.

Find Out More

Leave a Reply