Testing Automation Scripts with the new Maximo 7.6 “Testscript” method (Part 1: MBO based scripts)

Maximo introduced with Version 7.6 a new feature which allows you to test your automation scripts in context of a new or an existing Mbo as well as in context of the Maximo Integration Framework (MIF). The downside of that new function is, that I currently have not found any good documentation and that some features like the object path syntax are not self explaining. In this two part series I would like to introduce the new “Testscript” feature and explain how easy it is to use for your daily script testing. In part 1 we will cover the test of scripts in context of a Mbo and in part two I will show you how to test in context of the MIF.

The old styled “Run Script” testing is no longer visible but can be enabled again using the trick in my other post.

The first thing to mention if you want to test a script with the new Mbo-Test functionality is, that you need to have a script with an Object Launchpoint. Scripts with attribute launchpoints are not tested, or even worse if you have both: an object launch point and a attribute launch point on the same Mbo always the object script runs, even you select the attribute launch point script! (Might be confusing!). On the the other hand side you could utilize an Object Launchpoint testscript to set a certain attribute in a Mbo which then triggers the attribute launchpoint as well ūüėČ

Now lets create a very simple script with an object launch point for the ASSET object like the following:

print "Hello World"
print mbo.getString("ASSETNUM")

Press the “Test Script” button and you will see the following dialog:

At the top you will see information about the script and the selected Launchpoint we are running on.

With 1. you will select if we want the script to be tested against a newly created object or and existing object.

In 2. an object path can be specified if we want to reference an existing object. The format I currently found out is:

<OBJECT>[<SQL-WHERE>]

Examples could be:

ASSET[ASSETNUM='11200']
ASSET[ASSETNUM like '11%']
ASSET[ISRUNNING = 1]
ITEM[ITEMNUM='0815']

Important to remember, that you always get only a single resulting record to your script. This is the default behavior for an object script, where the resulting set is stored in the implicit Launchpoint variable mbo.

If you select Existing Object and specify an Object Path (remember to copy the Object Path to the clipboard – you have to reenter it for every test!) you can press the Test button.

You might see a result as follows:

  1. Data contains the resulting MBO in XML format.
  2. Log contains the output of the Print statements of the script.

With the Set attribute values section you can specify attributes which are overwritten from the original result. This is a nice feature when you need some testing data with certain specification (e.G. We need an asset in status of not running (ISRUNNING = 0), so we just need to specify:

So far we just have discussed the Existing Object path. If you like to create a New Object this also can be done with the testing function. The testing function basically calls an mboSet.addAtEnd() function to append a new record to the given MboSet. With the usage of Set attribute values you can predefine fields of the newly created Mbo before it is handed over to the Jython script.

A bit strange is, that if you try to create an Asset Object and do not specify an ASSETNUM you will get an error, that the asset field needs to be specified. If you will set the ASSETNUM field you will get an error, that it is readonly and cannot be set.

The only solution I found so far is to hardly overwrite the readonly check by using the¬†Field Flag “NOACCESSCHECK”:

from psdi.mbo import MboConstants
mbo.setValue("ASSETNUM", "ASS0815", MboConstants.NOACCESSCHECK )
mbo.setValue("DESCRIPTION", "New Test Asset!")

So far for this first tutorial on the new Test script capability. In the next part I will cover the capability to test automation scripts customizing the MIF Interface.

Missing “Launch Script” function in Autoscript Application in Maximo / ICD 7.6

Have you ever noticed that starting with Maximo or ICD Version 7.6 the ‚ÄěLaunch Script‚Äú action is missing in the Automationscript Application? You might missing the following running person:¬†Selection_042¬†If so you should read this post to solve this issue.

The new Maximo / ICD 7.6 still has all the functionality build in to run a script interactively. The only missing thing is a missing Signature Option “EXECUTE” in the automation Script application. To define this execute the following steps:

  1. Open Application Designer Application
    Goto > System Configuration > Plattform Configuration > Application Designer
  2. Search and open the “AUTOSCRIPT” application
  3. When you opened the “AUTOSCRIPT” application in Application Designer select from the “Select Action” Men√ľ:
    “Add/Modify Signature Options”
  4. Click on “New Row” in the dialog
  5. Define a new Signature Option “EXECUTE” with a Description “Launch Script”
  6. Goto > Security > Security Groups and add the newly created signature option to the Automationscript application.

Now you only have to logoff and logon again to see the new action in the application script application. In Maximo I had to add the newly created signature option to a Security Group. Maybe you have to go this extra step too…

Hope this will help you to easily test Scripts!

Run a Script interactively from ICD/Maximo

The Automation Script application provides the capability to directly run a script without having a launch point defined. This is useful to test some scripting capabilities or to run scripts performing maintenance tasks triggered by an user.

Attention:¬†If you are using Maximo or ICD in Version 7.6.x you might not find the “Launch Script” Action. In that case you should read this article to solve this issue first!

To test this behavior we will create a simple script without a launch point which lists all defined users from the ICD/Maximo system. Important is, that in this scenario no implicit variables are available and you have to initialize your MBO context manually based on the MXServer object. The scripts looks as follows:

#DESCRIPTION:Script to demonstrate usage of Run-Script function from GUI
from psdi.server import MXServer
from psdi.iface.mic import MicService

mxServer = MXServer.getMXServer()
micService = MicService(mxServer)
micService.init()
userInfo = micService.getNewUserInfo()

# Example: Loop over all Users....
userSet = mxServer.getMboSet('MAXUSER', userInfo)
userMbo = userSet.moveFirst()
while (userMbo != None):   
    print "User ",userMbo.getString("USERID")    
    userMbo = userSet.moveNext()

To run the script you should hit the following icon in the Taskbar of the Automation Script application:
Selection_042

The result should look as follows:
Selection_043